Browse Source

[core] inline buffer as part of DATA_UNSET key

(instead of key being (buffer *))
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
ad9b7e009b
  1. 42
      src/array.c
  2. 6
      src/array.h
  3. 10
      src/configfile-glue.c
  4. 36
      src/configfile.c
  5. 60
      src/configparser.y
  6. 5
      src/data_array.c
  7. 9
      src/data_config.c
  8. 5
      src/data_integer.c
  9. 5
      src/data_string.c
  10. 34
      src/gw_backend.c
  11. 10
      src/http-header-glue.c
  12. 2
      src/http_auth.c
  13. 8
      src/mod_alias.c
  14. 17
      src/mod_auth.c
  15. 2
      src/mod_authn_ldap.c
  16. 2
      src/mod_dirlisting.c
  17. 4
      src/mod_expire.c
  18. 28
      src/mod_extforward.c
  19. 2
      src/mod_magnet.c
  20. 4
      src/mod_maxminddb.c
  21. 6
      src/mod_openssl.c
  22. 68
      src/mod_proxy.c
  23. 6
      src/mod_redirect.c
  24. 6
      src/mod_rewrite.c
  25. 24
      src/mod_setenv.c
  26. 4
      src/mod_ssi.c
  27. 2
      src/mod_status.c
  28. 8
      src/mod_vhostdb_dbi.c
  29. 16
      src/mod_vhostdb_ldap.c
  30. 14
      src/mod_vhostdb_mysql.c
  31. 12
      src/mod_vhostdb_pgsql.c
  32. 4
      src/mod_webdav.c
  33. 14
      src/response.c
  34. 6
      src/server.c
  35. 4
      src/stat_cache.c
  36. 4
      src/t/test_array.c

42
src/array.c

@ -68,7 +68,7 @@ void array_reset_data_strings(array * const a) {
for (uint32_t i = 0; i < used; ++i) {
data_string * const ds = data[i];
/*force_assert(ds->type == TYPE_STRING);*/
buffer * const k = ds->key;
buffer * const k = &ds->key;
buffer * const v = ds->value;
if (k->size > BUFFER_MAX_REUSE_SIZE) buffer_reset(k);
if (v->size > BUFFER_MAX_REUSE_SIZE) buffer_reset(v);
@ -124,7 +124,7 @@ static int32_t array_get_index(const array * const a, const char * const k, cons
uint32_t lower = 0, upper = a->used;
while (lower != upper) {
uint32_t probe = (lower + upper) / 2;
const buffer * const b = a->data[probe]->key;
const buffer * const b = &a->data[probe]->key;
/* key is non-empty (0==b->used), though possibly blank (1==b->used),
* if inserted into key-value array */
/*force_assert(b && b->used);*/
@ -240,7 +240,7 @@ int * array_get_int_ptr(array * const a, const char * const k, const size_t klen
if (ipos >= 0) return &((data_integer *)a->data[ipos])->value;
data_integer * const di =array_insert_integer_at_pos(a,(uint32_t)(-ipos-1));
buffer_copy_string_len(di->key, k, klen);
buffer_copy_string_len(&di->key, k, klen);
di->value = 0;
return &di->value;
}
@ -250,14 +250,14 @@ buffer * array_get_buf_ptr(array * const a, const char * const k, const size_t k
if (ipos >= 0) return ((data_string *)a->data[ipos])->value;
data_string * const ds = array_insert_string_at_pos(a, (uint32_t)(-ipos-1));
buffer_copy_string_len(ds->key, k, klen);
buffer_copy_string_len(&ds->key, k, klen);
buffer_clear(ds->value);
return ds->value;
}
void array_insert_value(array * const a, const char * const v, const size_t vlen) {
data_string * const ds = array_insert_string_at_pos(a, a->used);
buffer_clear(ds->key);
buffer_clear(&ds->key);
buffer_copy_string_len(ds->value, v, vlen);
}
@ -267,13 +267,13 @@ static data_unset **array_find_or_insert(array * const a, data_unset * const ent
force_assert(NULL != entry);
/* push value onto end of array if there is no key */
if (buffer_is_empty(entry->key)) {
if (buffer_is_empty(&entry->key)) {
array_insert_data_at_pos(a, entry, a->used);
return NULL;
}
/* try to find the entry */
const int32_t ipos = array_get_index(a, CONST_BUF_LEN(entry->key));
const int32_t ipos = array_get_index(a, CONST_BUF_LEN(&entry->key));
if (ipos >= 0) return &a->data[ipos];
array_insert_data_at_pos(a, entry, (uint32_t)(-ipos - 1));
@ -303,7 +303,7 @@ void array_insert_unique(array * const a, data_unset * const entry) {
int array_is_vlist(const array * const a) {
for (uint32_t i = 0; i < a->used; ++i) {
data_unset *du = a->data[i];
if (!buffer_is_empty(du->key) || du->type != TYPE_STRING) return 0;
if (!buffer_is_empty(&du->key) || du->type != TYPE_STRING) return 0;
}
return 1;
}
@ -311,7 +311,7 @@ int array_is_vlist(const array * const a) {
int array_is_kvany(const array * const a) {
for (uint32_t i = 0; i < a->used; ++i) {
data_unset *du = a->data[i];
if (buffer_is_empty(du->key)) return 0;
if (buffer_is_empty(&du->key)) return 0;
}
return 1;
}
@ -319,7 +319,7 @@ int array_is_kvany(const array * const a) {
int array_is_kvarray(const array * const a) {
for (uint32_t i = 0; i < a->used; ++i) {
data_unset *du = a->data[i];
if (buffer_is_empty(du->key) || du->type != TYPE_ARRAY) return 0;
if (buffer_is_empty(&du->key) || du->type != TYPE_ARRAY) return 0;
}
return 1;
}
@ -327,7 +327,7 @@ int array_is_kvarray(const array * const a) {
int array_is_kvstring(const array * const a) {
for (uint32_t i = 0; i < a->used; ++i) {
data_unset *du = a->data[i];
if (buffer_is_empty(du->key) || du->type != TYPE_STRING) return 0;
if (buffer_is_empty(&du->key) || du->type != TYPE_STRING) return 0;
}
return 1;
}
@ -342,7 +342,7 @@ data_unset *
array_match_key_prefix_klen (const array * const a, const char * const s, const size_t slen)
{
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const key = a->data[i]->key;
const buffer * const key = &a->data[i]->key;
const size_t klen = buffer_string_length(key);
if (klen <= slen && 0 == memcmp(s, key->ptr, klen))
return a->data[i];
@ -354,7 +354,7 @@ data_unset *
array_match_key_prefix_nc_klen (const array * const a, const char * const s, const size_t slen)
{
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const key = a->data[i]->key;
const buffer * const key = &a->data[i]->key;
const size_t klen = buffer_string_length(key);
if (klen <= slen && buffer_eq_icase_ssn(s, key->ptr, klen))
return a->data[i];
@ -409,7 +409,7 @@ array_match_key_suffix (const array * const a, const buffer * const b)
const char * const end = b->ptr + blen;
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const key = a->data[i]->key;
const buffer * const key = &a->data[i]->key;
const size_t klen = buffer_string_length(key);
if (klen <= blen && 0 == memcmp(end - klen, key->ptr, klen))
return a->data[i];
@ -424,7 +424,7 @@ array_match_key_suffix_nc (const array * const a, const buffer * const b)
const char * const end = b->ptr + blen;
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const key = a->data[i]->key;
const buffer * const key = &a->data[i]->key;
const size_t klen = buffer_string_length(key);
if (klen <= blen && buffer_eq_icase_ssn(end - klen, key->ptr, klen))
return a->data[i];
@ -469,7 +469,7 @@ array_match_path_or_ext (const array * const a, const buffer * const b)
for (uint32_t i = 0; i < a->used; ++i) {
/* check extension in the form "^/path" or ".ext$" */
const buffer * const key = a->data[i]->key;
const buffer * const key = &a->data[i]->key;
const size_t klen = buffer_string_length(key);
if (klen <= blen
&& 0 == memcmp((*(key->ptr) == '/' ? b->ptr : b->ptr + blen - klen),
@ -495,7 +495,7 @@ void array_print_indent(int depth) {
size_t array_get_max_key_length(const array * const a) {
size_t maxlen = 0;
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const k = a->data[i]->key;
const buffer * const k = &a->data[i]->key;
size_t len = buffer_string_length(k);
if (len > maxlen) {
@ -515,7 +515,7 @@ int array_print(const array * const a, int depth) {
}
for (i = 0; i < a->used && oneline; i++) {
data_unset *du = a->data[i];
if (!buffer_is_empty(du->key)) {
if (!buffer_is_empty(&du->key)) {
oneline = 0;
break;
}
@ -546,15 +546,15 @@ int array_print(const array * const a, int depth) {
for (i = 0; i < a->used; i++) {
data_unset *du = a->data[i];
array_print_indent(depth + 1);
if (!buffer_is_empty(du->key)) {
if (!buffer_is_empty(&du->key)) {
int j;
if (i && (i % 5) == 0) {
fprintf(stdout, "# %u\n", i);
array_print_indent(depth + 1);
}
fprintf(stdout, "\"%s\"", du->key->ptr);
for (j = maxlen - buffer_string_length(du->key); j > 0; j--) {
fprintf(stdout, "\"%s\"", du->key.ptr);
for (j = maxlen - buffer_string_length(&du->key); j > 0; j--) {
fprintf(stdout, " ");
}
fprintf(stdout, " => ");

6
src/array.h

@ -15,9 +15,9 @@ struct data_methods {
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_OTHER, TYPE_ARRAY, TYPE_INTEGER, TYPE_DONOTUSE, TYPE_CONFIG } data_type_t;
#define DATA_UNSET \
buffer *key; \
data_type_t type; \
const struct data_methods *fn /* function table */
buffer key; \
const struct data_methods *fn; /* function table */ \
data_type_t type
typedef struct data_unset {
DATA_UNSET;

10
src/configfile-glue.c

@ -61,7 +61,7 @@ int config_insert_values_internal(server *srv, const array *ca, const config_val
} else {
log_error_write(srv, __FILE__, __LINE__, "sssbsd",
"the value of an array can only be a string, variable:",
cv[i].key, "[", ds->key, "], type:", ds->type);
cv[i].key, "[", &ds->key, "], type:", ds->type);
return -1;
}
@ -197,7 +197,7 @@ int config_insert_values_global(server *srv, const array *ca, const config_value
continue;
}
array_set_key_value(srv->config_touched, CONST_BUF_LEN(du->key), CONST_STR_LEN(""));
array_set_key_value(srv->config_touched, CONST_BUF_LEN(&du->key), CONST_STR_LEN(""));
}
return config_insert_values_internal(srv, ca, cv, scope);
@ -281,7 +281,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, con
* if the parent is not decided yet or false, we can't be true either
*/
if (con->conf.log_condition_handling) {
log_error_write(srv, __FILE__, __LINE__, "sb", "go parent", dc->parent->key);
log_error_write(srv, __FILE__, __LINE__, "sb", "go parent", &dc->parent->key);
}
switch (config_check_cond_cached(srv, con, dc->parent)) {
@ -304,7 +304,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, con
* was evaluated as "false" (not unset/skipped/true)
*/
if (con->conf.log_condition_handling) {
log_error_write(srv, __FILE__, __LINE__, "sb", "go prev", dc->prev->key);
log_error_write(srv, __FILE__, __LINE__, "sb", "go prev", &dc->prev->key);
}
/* make sure prev is checked first */
@ -326,7 +326,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, con
if (con->conf.log_condition_handling) {
log_error_write(srv, __FILE__, __LINE__, "dss",
dc->comp,
dc->key->ptr,
dc->key.ptr,
"not available yet");
}

36
src/configfile.c

@ -53,7 +53,7 @@ static void config_warn_openssl_module (server *srv) {
const data_config *config = (data_config const*)srv->config_context->data[i];
for (size_t j = 0; j < config->value->used; ++j) {
data_unset *du = config->value->data[j];
if (0 == strncmp(du->key->ptr, "ssl.", sizeof("ssl.")-1)) {
if (0 == strncmp(du->key.ptr, "ssl.", sizeof("ssl.")-1)) {
/* mod_openssl should be loaded after mod_extforward */
array_insert_value(srv->srvconf.modules, CONST_STR_LEN("mod_openssl"));
log_error_write(srv, __FILE__, __LINE__, "S", "Warning: please add \"mod_openssl\" to server.modules list in lighttpd.conf. A future release of lighttpd 1.4.x *will not* automatically load mod_openssl and lighttpd *will not* use SSL/TLS where your lighttpd.conf contains ssl.* directives");
@ -85,50 +85,50 @@ static int config_http_parseopts (server *srv, array *a) {
else {
log_error_write(srv, __FILE__, __LINE__, "sbsbs",
"unrecognized value for server.http-parseopts:",
ds->key, "=>", ds->value,
&ds->key, "=>", ds->value,
"(expect \"[enable|disable]\")");
rc = 0;
}
if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-normalize")))
if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-normalize")))
opt = HTTP_PARSEOPT_URL_NORMALIZE;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-normalize-unreserved")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-normalize-unreserved")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_UNRESERVED;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-normalize-required")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-normalize-required")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-ctrls-reject")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-ctrls-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-path-backslash-trans")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-path-backslash-trans")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-path-2f-decode")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-path-2f-decode")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-path-2f-reject")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-path-2f-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-path-dotseg-remove")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-path-dotseg-remove")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-path-dotseg-reject")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-path-dotseg-reject")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-query-20-plus")))
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("url-query-20-plus")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("header-strict"))) {
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("header-strict"))) {
srv->srvconf.http_header_strict = val;
continue;
}
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("host-strict"))) {
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("host-strict"))) {
srv->srvconf.http_host_strict = val;
continue;
}
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("host-normalize"))) {
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("host-normalize"))) {
srv->srvconf.http_host_normalize = val;
continue;
}
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("method-get-body"))) {
else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("method-get-body"))) {
srv->srvconf.http_method_get_body = val;
continue;
}
else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"unrecognized key for server.http-parseopts:",
ds->key);
&ds->key);
rc = 0;
continue;
}
@ -1503,7 +1503,7 @@ int config_read(server *srv, const char *fn) {
}
dc = data_config_init();
buffer_copy_string_len(dc->key, CONST_STR_LEN("global"));
buffer_copy_string_len(&dc->key, CONST_STR_LEN("global"));
force_assert(context.all_configs->used == 0);
dc->context_ndx = context.all_configs->used;

60
src/configparser.y

@ -52,12 +52,12 @@ static data_unset *configparser_get_variable(config_t *ctx, const buffer *key) {
#endif
for (dc = ctx->current; dc; dc = dc->parent) {
#if 0
fprintf(stderr, "get var on block: %s\n", dc->key->ptr);
fprintf(stderr, "get var on block: %s\n", dc->key.ptr);
array_print(dc->value, 0);
#endif
if (NULL != (du = array_get_element_klen(dc->value, CONST_BUF_LEN(key)))) {
data_unset *du_copy = du->fn->copy(du);
buffer_clear(du_copy->key);
buffer_clear(&du_copy->key);
return du_copy;
}
}
@ -103,10 +103,10 @@ static data_unset *configparser_merge_data(data_unset *op1, const data_unset *op
for (i = 0; i < src->used; i ++) {
du = (data_unset *)src->data[i];
if (du) {
if (buffer_is_empty(du->key) || !array_get_element_klen(dst, CONST_BUF_LEN(du->key))) {
if (buffer_is_empty(&du->key) || !array_get_element_klen(dst, CONST_BUF_LEN(&du->key))) {
array_insert_unique(dst, du->fn->copy(du));
} else {
fprintf(stderr, "Duplicate array-key '%s'\n", du->key->ptr);
fprintf(stderr, "Duplicate array-key '%s'\n", du->key.ptr);
op1->fn->free(op1);
return NULL;
}
@ -191,19 +191,19 @@ metaline ::= EOL.
varline ::= key(A) ASSIGN expression(B). {
if (ctx->ok) {
buffer_copy_buffer(B->key, A);
buffer_copy_buffer(&B->key, A);
if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) {
fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n",
ctx->current->context_ndx,
ctx->current->key->ptr, A->ptr);
ctx->current->key.ptr, A->ptr);
ctx->ok = 0;
} else if (NULL == array_get_element_klen(ctx->current->value, CONST_BUF_LEN(B->key))) {
} else if (NULL == array_get_element_klen(ctx->current->value, CONST_BUF_LEN(&B->key))) {
array_insert_unique(ctx->current->value, B);
B = NULL;
} else {
fprintf(stderr, "Duplicate config variable in conditional %d %s: %s\n",
ctx->current->context_ndx,
ctx->current->key->ptr, B->key->ptr);
ctx->current->key.ptr, B->key.ptr);
ctx->ok = 0;
}
}
@ -218,10 +218,10 @@ varline ::= key(A) FORCE_ASSIGN expression(B). {
if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) {
fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n",
ctx->current->context_ndx,
ctx->current->key->ptr, A->ptr);
ctx->current->key.ptr, A->ptr);
ctx->ok = 0;
} else {
buffer_copy_buffer(B->key, A);
buffer_copy_buffer(&B->key, A);
array_replace(ctx->current->value, B);
B = NULL;
}
@ -240,7 +240,7 @@ varline ::= key(A) APPEND expression(B). {
if (strncmp(A->ptr, "env.", sizeof("env.") - 1) == 0) {
fprintf(stderr, "Appending env variable is not supported in conditional %d %s: %s\n",
ctx->current->context_ndx,
ctx->current->key->ptr, A->ptr);
ctx->current->key.ptr, A->ptr);
ctx->ok = 0;
} else if (NULL != (du = array_extract_element_klen(vars, CONST_BUF_LEN(A))) || NULL != (du = configparser_get_variable(ctx, A))) {
du = configparser_merge_data(du, B);
@ -248,11 +248,11 @@ varline ::= key(A) APPEND expression(B). {
ctx->ok = 0;
}
else {
buffer_copy_buffer(du->key, A);
buffer_copy_buffer(&du->key, A);
array_insert_unique(ctx->current->value, du);
}
} else {
buffer_copy_buffer(B->key, A);
buffer_copy_buffer(&B->key, A);
array_insert_unique(ctx->current->value, B);
B = NULL;
}
@ -360,13 +360,13 @@ array(A) ::= LPARAN aelements(B) RPARAN. {
aelements(A) ::= aelements(C) COMMA aelement(B). {
A = NULL;
if (ctx->ok) {
if (buffer_is_empty(B->key) ||
NULL == array_get_element_klen(C, CONST_BUF_LEN(B->key))) {
if (buffer_is_empty(&B->key) ||
NULL == array_get_element_klen(C, CONST_BUF_LEN(&B->key))) {
array_insert_unique(C, B);
B = NULL;
} else {
fprintf(stderr, "Error: duplicate array-key: %s. Please get rid of the duplicate entry.\n",
B->key->ptr);
B->key.ptr);
ctx->ok = 0;
}
@ -402,7 +402,7 @@ aelement(A) ::= expression(B). {
aelement(A) ::= stringop(B) ARRAY_ASSIGN expression(C). {
A = NULL;
if (ctx->ok) {
buffer_copy_buffer(C->key, B);
buffer_copy_buffer(&C->key, B);
A = C;
C = NULL;
@ -463,35 +463,35 @@ condlines(A) ::= condlines(B) eols ELSE cond_else(C). {
if (ctx->ok) {
size_t pos;
data_config *dc;
dc = (data_config *)array_extract_element_klen(ctx->all_configs, CONST_BUF_LEN(C->key));
dc = (data_config *)array_extract_element_klen(ctx->all_configs, CONST_BUF_LEN(&C->key));
force_assert(C == dc);
buffer_copy_buffer(C->key, B->key);
buffer_copy_buffer(&C->key, &B->key);
C->comp = B->comp;
/*buffer_copy_buffer(C->comp_key, B->comp_key);*/
/*C->string = buffer_init_buffer(B->string);*/
pos = buffer_string_length(C->key)-buffer_string_length(B->string)-2;
pos = buffer_string_length(&C->key)-buffer_string_length(B->string)-2;
switch(B->cond) {
case CONFIG_COND_NE:
C->key->ptr[pos] = '='; /* opposite cond */
C->key.ptr[pos] = '='; /* opposite cond */
/*buffer_copy_string_len(C->op, CONST_STR_LEN("=="));*/
break;
case CONFIG_COND_EQ:
C->key->ptr[pos] = '!'; /* opposite cond */
C->key.ptr[pos] = '!'; /* opposite cond */
/*buffer_copy_string_len(C->op, CONST_STR_LEN("!="));*/
break;
case CONFIG_COND_NOMATCH:
C->key->ptr[pos] = '='; /* opposite cond */
C->key.ptr[pos] = '='; /* opposite cond */
/*buffer_copy_string_len(C->op, CONST_STR_LEN("=~"));*/
break;
case CONFIG_COND_MATCH:
C->key->ptr[pos] = '!'; /* opposite cond */
C->key.ptr[pos] = '!'; /* opposite cond */
/*buffer_copy_string_len(C->op, CONST_STR_LEN("!~"));*/
break;
default: /* should not happen; CONFIG_COND_ELSE checked further above */
force_assert(0);
}
if (NULL == (dc = configparser_get_data_config(ctx->all_configs, CONST_BUF_LEN(C->key)))) {
if (NULL == (dc = configparser_get_data_config(ctx->all_configs, CONST_BUF_LEN(&C->key)))) {
/* re-insert into ctx->all_configs with new C->key */
array_insert_unique(ctx->all_configs, (data_unset *)C);
C->prev = B;
@ -571,7 +571,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
}
b = buffer_init();
buffer_copy_buffer(b, ctx->current->key);
buffer_copy_buffer(b, &ctx->current->key);
buffer_append_string_len(b, CONST_STR_LEN("/"));
buffer_append_string_buffer(b, B);
buffer_append_string_buffer(b, C);
@ -607,7 +607,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
dc = data_config_init();
buffer_copy_buffer(dc->key, b);
buffer_copy_buffer(&dc->key, b);
buffer_copy_buffer(dc->op, op);
buffer_copy_buffer(dc->comp_tag, C);
buffer_copy_buffer(dc->comp_key, B);
@ -739,9 +739,9 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
context_else ::= . {
if (ctx->ok) {
data_config *dc = data_config_init();
buffer_copy_buffer(dc->key, ctx->current->key);
buffer_append_string_len(dc->key, CONST_STR_LEN("/"));
buffer_append_string_len(dc->key, CONST_STR_LEN("else_tmp_token"));
buffer_copy_buffer(&dc->key, &ctx->current->key);
buffer_append_string_len(&dc->key, CONST_STR_LEN("/"));
buffer_append_string_len(&dc->key, CONST_STR_LEN("else_tmp_token"));
dc->cond = CONFIG_COND_ELSE;
configparser_push(ctx, dc, 1);
}

5
src/data_array.c

@ -10,7 +10,7 @@ static data_unset *data_array_copy(const data_unset *s) {
data_array *src = (data_array *)s;
data_array *ds = data_array_init();
if (!buffer_is_empty(src->key)) buffer_copy_buffer(ds->key, src->key);
if (!buffer_is_empty(&src->key)) buffer_copy_buffer(&ds->key, &src->key);
array_free(ds->value);
ds->value = array_init_array(src->value);
return (data_unset *)ds;
@ -19,7 +19,7 @@ static data_unset *data_array_copy(const data_unset *s) {
static void data_array_free(data_unset *d) {
data_array *ds = (data_array *)d;
buffer_free(ds->key);
free(ds->key.ptr);
array_free(ds->value);
free(d);
@ -53,7 +53,6 @@ data_array *data_array_init(void) {
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = array_init();
ds->type = TYPE_ARRAY;

9
src/data_config.c

@ -17,7 +17,7 @@ static data_unset *data_config_copy(const data_unset *s) {
data_config *ds = data_config_init();
ds->comp = src->comp;
if (!buffer_is_empty(src->key)) buffer_copy_buffer(ds->key, src->key);
if (!buffer_is_empty(&src->key)) buffer_copy_buffer(&ds->key, &src->key);
buffer_copy_buffer(ds->comp_tag, src->comp_tag);
buffer_copy_buffer(ds->comp_key, src->comp_key);
array_free(ds->value);
@ -29,7 +29,7 @@ __attribute_cold__
static void data_config_free(data_unset *d) {
data_config *ds = (data_config *)d;
buffer_free(ds->key);
free(ds->key.ptr);
buffer_free(ds->op);
buffer_free(ds->comp_tag);
buffer_free(ds->comp_key);
@ -80,11 +80,11 @@ static void data_config_print(const data_unset *d, int depth) {
maxlen = array_get_max_key_length(a);
for (i = 0; i < a->used; i ++) {
data_unset *du = a->data[i];
size_t len = buffer_string_length(du->key);
size_t len = buffer_string_length(&du->key);
size_t j;
array_print_indent(depth);
fprintf(stdout, "%s", du->key->ptr);
fprintf(stdout, "%s", du->key.ptr);
for (j = maxlen - len; j > 0; j --) {
fprintf(stdout, " ");
}
@ -137,7 +137,6 @@ data_config *data_config_init(void) {
ds = calloc(1, sizeof(*ds));
ds->key = buffer_init();
ds->op = buffer_init();
ds->comp_tag = buffer_init();
ds->comp_key = buffer_init();

5
src/data_integer.c

@ -11,7 +11,7 @@ static data_unset *data_integer_copy(const data_unset *s) {
data_integer *src = (data_integer *)s;
data_integer *ds = data_integer_init();
if (!buffer_is_empty(src->key)) buffer_copy_buffer(ds->key, src->key);
if (!buffer_is_empty(&src->key)) buffer_copy_buffer(&ds->key, &src->key);
ds->value = src->value;
return (data_unset *)ds;
}
@ -19,7 +19,7 @@ static data_unset *data_integer_copy(const data_unset *s) {
static void data_integer_free(data_unset *d) {
data_integer *ds = (data_integer *)d;
buffer_free(ds->key);
free(ds->key.ptr);
free(d);
}
@ -54,7 +54,6 @@ data_integer *data_integer_init(void) {
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = 0;
ds->type = TYPE_INTEGER;

5
src/data_string.c

@ -11,7 +11,7 @@ static data_unset *data_string_copy(const data_unset *s) {
data_string *src = (data_string *)s;
data_string *ds = data_string_init();
if (!buffer_is_empty(src->key)) buffer_copy_buffer(ds->key, src->key);
if (!buffer_is_empty(&src->key)) buffer_copy_buffer(&ds->key, &src->key);
buffer_copy_buffer(ds->value, src->value);
return (data_unset *)ds;
}
@ -19,7 +19,7 @@ static data_unset *data_string_copy(const data_unset *s) {
static void data_string_free(data_unset *d) {
data_string *ds = (data_string *)d;
buffer_free(ds->key);
free(ds->key.ptr);
buffer_free(ds->value);
free(d);
@ -81,7 +81,6 @@ data_string *data_string_init(void) {
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = buffer_init();
ds->type = TYPE_STRING;

34
src/gw_backend.c

@ -542,7 +542,7 @@ static int gw_spawn_connection(server *srv, gw_host *host, gw_proc *proc, int de
for (i = 0; i < host->bin_env->used; ++i) {
data_string *ds = (data_string *)host->bin_env->data[i];
env_add(&env, CONST_BUF_LEN(ds->key), CONST_BUF_LEN(ds->value));
env_add(&env, CONST_BUF_LEN(&ds->key), CONST_BUF_LEN(ds->value));
}
for (i = 0; i < env.used; ++i) {
@ -1259,7 +1259,7 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
if (da_host->type != TYPE_ARRAY || !array_is_kvany(da_host->value)){
log_error_write(srv, __FILE__, __LINE__, "SBS",
"unexpected value for gw.server near [",
da_host->key, "](string); expected ( \"ext\" => ( \"backend-label\" => ( \"key\" => \"value\" )))");
&da_host->key, "](string); expected ( \"ext\" => ( \"backend-label\" => ( \"key\" => \"value\" )))");
goto error;
}
@ -1267,7 +1267,7 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
host = gw_host_init();
buffer_clear(gw_mode);
buffer_copy_buffer(host->id, da_host->key);
buffer_copy_buffer(host->id, &da_host->key);
host->check_local = 1;
host->min_procs = 4;
@ -1313,10 +1313,10 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
}
for (size_t m = 0; m < da_host->value->used; ++m) {
if (NULL != strchr(da_host->value->data[m]->key->ptr, '_')) {
if (NULL != strchr(da_host->value->data[m]->key.ptr, '_')) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"incorrect directive contains underscore ('_') instead of dash ('-'):",
da_host->value->data[m]->key);
&da_host->value->data[m]->key);
}
}
@ -1324,9 +1324,9 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
&& !buffer_string_is_empty(host->unixsocket)) {
log_error_write(srv, __FILE__, __LINE__, "sbsbsbs",
"either host/port or socket have to be set in:",
da->key, "= (",
da_ext->key, " => (",
da_host->key, " ( ...");
&da->key, "= (",
&da_ext->key, " => (",
&da_host->key, " ( ...");
goto error;
}
@ -1343,9 +1343,9 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
if (buffer_string_length(host->unixsocket) + 1 > sizeof(un.sun_path) - 2) {
log_error_write(srv, __FILE__, __LINE__, "sbsbsbs",
"unixsocket is too long in:",
da->key, "= (",
da_ext->key, " => (",
da_host->key, " ( ...");
&da->key, "= (",
&da_ext->key, " => (",
&da_host->key, " ( ...");
goto error;
}
@ -1373,9 +1373,9 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
buffer_string_is_empty(host->bin_path)) {
log_error_write(srv, __FILE__, __LINE__, "sbsbsbs",
"host or bin-path have to be set in:",
da->key, "= (",
da_ext->key, " => (",
da_host->key, " ( ...");
&da->key, "= (",
&da_ext->key, " => (",
&da_host->key, " ( ...");
goto error;
} else if (0 == host->port) {
@ -1567,14 +1567,14 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
* request body from client and can authorizer or deny request
* prior to receiving the full upload)
*/
gw_extension_insert(s->exts, da_ext->key, host);
gw_extension_insert(s->exts, &da_ext->key, host);
if (host_mode == GW_AUTHORIZER) {
++host->refcount;
gw_extension_insert(s->exts_auth, da_ext->key, host);
gw_extension_insert(s->exts_auth, &da_ext->key, host);
} else if (host_mode == GW_RESPONDER) {
++host->refcount;
gw_extension_insert(s->exts_resp, da_ext->key, host);
gw_extension_insert(s->exts_resp, &da_ext->key, host);
} /*(else should have been rejected above)*/
host = NULL;

10
src/http-header-glue.c

@ -1532,16 +1532,16 @@ int http_cgi_headers (server *srv, connection *con, http_cgi_opts *opts, http_cg
for (n = 0; n < con->request.headers->used; n++) {
data_string *ds = (data_string *)con->request.headers->data[n];
if (!buffer_string_is_empty(ds->value) && !buffer_is_empty(ds->key)) {
if (!buffer_string_is_empty(ds->value) && !buffer_is_empty(&ds->key)) {
/* Security: Do not emit HTTP_PROXY in environment.
* Some executables use HTTP_PROXY to configure
* outgoing proxy. See also https://httpoxy.org/ */
if (buffer_is_equal_caseless_string(ds->key,
if (buffer_is_equal_caseless_string(&ds->key,
CONST_STR_LEN("Proxy"))) {
continue;
}
buffer_copy_string_encoded_cgi_varnames(srv->tmp_buf,
CONST_BUF_LEN(ds->key), 1);
CONST_BUF_LEN(&ds->key), 1);
rc |= cb(vdata, CONST_BUF_LEN(srv->tmp_buf),
CONST_BUF_LEN(ds->value));
}
@ -1551,9 +1551,9 @@ int http_cgi_headers (server *srv, connection *con, http_cgi_opts *opts, http_cg
for (n = 0; n < con->environment->used; n++) {
data_string *ds = (data_string *)con->environment->data[n];
if (!buffer_is_empty(ds->value) && !buffer_is_empty(ds->key)) {
if (!buffer_is_empty(ds->value) && !buffer_is_empty(&ds->key)) {
buffer_copy_string_encoded_cgi_varnames(srv->tmp_buf,
CONST_BUF_LEN(ds->key), 0);
CONST_BUF_LEN(&ds->key), 0);
rc |= cb(vdata, CONST_BUF_LEN(srv->tmp_buf),
CONST_BUF_LEN(ds->value));
}

2
src/http_auth.c

@ -138,7 +138,7 @@ void http_auth_require_free (http_auth_require_t * const require)
static int http_auth_array_contains (const array * const a, const char * const k, const size_t klen)
{
for (size_t i = 0, used = a->used; i < used; ++i) {
if (buffer_is_equal_string(a->data[i]->key, k, klen)) {
if (buffer_is_equal_string(&a->data[i]->key, k, klen)) {
return 1;
}
}

8
src/mod_alias.c

@ -99,9 +99,9 @@ SETDEFAULTS_FUNC(mod_alias_set_defaults) {
size_t j, k;
for (j = 0; j < a->used; j ++) {
const buffer *prefix = a->data[j]->key;
const buffer *prefix = &a->data[j]->key;
for (k = j + 1; k < a->used; k ++) {
const buffer *key = a->data[k]->key;
const buffer *key = &a->data[k]->key;
if (buffer_string_length(key) < buffer_string_length(prefix)) {
break;
@ -179,13 +179,13 @@ PHYSICALPATH_FUNC(mod_alias_physical_handler) {
/* check for path traversal in url-path following alias if key
* does not end in slash, but replacement value ends in slash */
alias_len = buffer_string_length(ds->key);
alias_len = buffer_string_length(&ds->key);
if (uri_ptr[alias_len] == '.') {
char *s = uri_ptr + alias_len + 1;
if (*s == '.') ++s;
if (*s == '/' || *s == '\0') {
size_t vlen = buffer_string_length(ds->value);
if (0 != alias_len && ds->key->ptr[alias_len-1] != '/'
if (0 != alias_len && ds->key.ptr[alias_len-1] != '/'
&& 0 != vlen && ds->value->ptr[vlen-1] == '/') {
con->http_status = 403;
return HANDLER_FINISHED;

17
src/mod_auth.c

@ -93,7 +93,7 @@ typedef struct {
static void data_auth_free(data_unset *d)
{
data_auth * const dauth = (data_auth *)d;
buffer_free(dauth->key);
free(dauth->key.ptr);
http_auth_require_free(dauth->require);
free(dauth);
}
@ -111,7 +111,6 @@ static data_auth *data_auth_init(void)
dauth->type = TYPE_OTHER;
dauth->fn = &fn;
dauth->key = buffer_init();
dauth->require = http_auth_require_init();
return dauth;
@ -342,19 +341,19 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
for (m = 0; m < da_file->value->used; m++) {
if (da_file->value->data[m]->type == TYPE_STRING) {
data_string *ds = (data_string *)da_file->value->data[m];
if (buffer_is_equal_string(ds->key, CONST_STR_LEN("method"))) {
if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("method"))) {
method = ds->value;
} else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("realm"))) {
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("realm"))) {
realm = ds->value;
} else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("require"))) {
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("require"))) {
require = ds->value;
} else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("algorithm"))) {
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("algorithm"))) {
algos = ds->value;
} else {
log_error_write(srv, __FILE__, __LINE__, "ssbs",
"the field is unknown in:",
"auth.require = ( \"...\" => ( ..., -> \"",
da_file->value->data[m]->key,
&da_file->value->data[m]->key,
"\" <- => \"...\" ) )");
return HANDLER_ERROR;
@ -363,7 +362,7 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
log_error_write(srv, __FILE__, __LINE__, "ssbs",
"a string was expected for:",
"auth.require = ( \"...\" => ( ..., -> \"",
da_file->value->data[m]->key,
&da_file->value->data[m]->key,
"\" <- => \"...\" ) )");
return HANDLER_ERROR;
@ -410,7 +409,7 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
if (require) { /*(always true at this point)*/
data_auth * const dauth = data_auth_init();
buffer_copy_buffer(dauth->key, da_file->key);
buffer_copy_buffer(&dauth->key, &da_file->key);
dauth->require->scheme = auth_scheme;
dauth->require->algorithm = algorithm;
buffer_copy_buffer(dauth->require->realm, realm);

2
src/mod_authn_ldap.c

@ -578,7 +578,7 @@ static handler_t mod_authn_ldap_memberOf(server *srv, plugin_config *s, const ht
buffer_append_string_len(filter, CONST_STR_LEN(")"));
for (size_t i = 0; i < groups->used; ++i) {
char *base = groups->data[i]->key->ptr;
char *base = groups->data[i]->key.ptr;
LDAPMessage *lm = mod_authn_ldap_search(srv, s, base, filter->ptr);
if (NULL != lm) {
int count = ldap_count_entries(s->ldap, lm);

2
src/mod_dirlisting.c

@ -300,7 +300,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
if (du_exclude->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "sssbs",
"unexpected type for key: ", CONFIG_EXCLUDE, "[",
du_exclude->key, "](string)");
&du_exclude->key, "](string)");
return HANDLER_ERROR;
}

4
src/mod_expire.c

@ -270,13 +270,13 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) {
for (k = 0; k < s->expire_mimetypes->used; k++) {
data_string *ds = (data_string *)s->expire_mimetypes->data[k];
size_t klen = buffer_string_length(ds->key);
size_t klen = buffer_string_length(&ds->key);
/*(omit trailing '*', if present, from prefix match)*/
/*(not usually a good idea to modify array keys
* since doing so might break array_get_element_klen() search,
* but array use in this module only walks array)*/
if (klen && ds->key->ptr[klen-1] == '*') buffer_string_set_length(ds->key, klen-1);
if (klen && ds->key.ptr[klen-1] == '*') buffer_string_set_length(&ds->key, klen-1);
/* parse lines */
if (-1 == mod_expire_get_offset(srv, p, ds->value, NULL)) {

28
src/mod_extforward.c

@ -231,13 +231,13 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
s->forward_all = (NULL == allds) ? 0 : buffer_eq_icase_slen(allds->value, CONST_STR_LEN("trust")) ? 1 : -1;
for (size_t j = 0; j < s->forwarder->used; ++j) {
data_string * const ds = (data_string *)s->forwarder->data[j];
char * const nm_slash = strchr(ds->key->ptr, '/');
char * const nm_slash = strchr(ds->key.ptr, '/');
if (!buffer_eq_icase_slen(ds->value, CONST_STR_LEN("trust"))) {
if (!buffer_eq_icase_slen(ds->value, CONST_STR_LEN("untrusted"))) {
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: expect \"trust\", not \"", ds->key, "\" => \"", ds->value, "\"; treating as untrusted");
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: expect \"trust\", not \"", &ds->key, "\" => \"", ds->value, "\"; treating as untrusted");
}
if (NULL != nm_slash) {
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: untrusted CIDR masks are ignored (\"", ds->key, "\" => \"", ds->value, "\")");
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: untrusted CIDR masks are ignored (\"", &ds->key, "\" => \"", ds->value, "\")");
}
buffer_clear(ds->value); /* empty is untrusted */
continue;
@ -248,7 +248,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
const int nm_bits = strtol(nm_slash + 1, &err, 10);
int rc;
if (*err || nm_bits <= 0) {
log_error_write(srv, __FILE__, __LINE__, "sbs", "ERROR: invalid netmask:", ds->key, err);
log_error_write(srv, __FILE__, __LINE__, "sbs", "ERROR: invalid netmask:", &ds->key, err);
return HANDLER_ERROR;
}
if (NULL == s->forward_masks) {
@ -263,7 +263,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
sm = s->forward_masks->addrs + s->forward_masks->used++;
sm->bits = nm_bits;
*nm_slash = '\0';
rc = sock_addr_from_str_numeric(srv, &sm->addr, ds->key->ptr);
rc = sock_addr_from_str_numeric(srv, &sm->addr, ds->key.ptr);
*nm_slash = '/';
if (1 != rc) return HANDLER_ERROR;
buffer_clear(ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */
@ -292,23 +292,23 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
proxy_forwarded_t param;
data_unset *du = s->opts_params->data[j];
#if 0 /*("for" and "proto" historical behavior: always enabled)*/
if (buffer_is_equal_string(du->key, CONST_STR_LEN("by"))) {
if (buffer_is_equal_string(&du->key, CONST_STR_LEN("by"))) {
param = PROXY_FORWARDED_BY;
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("for"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("for"))) {
param = PROXY_FORWARDED_FOR;
} else
#endif
if (buffer_is_equal_string(du->key, CONST_STR_LEN("host"))) {
if (buffer_is_equal_string(&du->key, CONST_STR_LEN("host"))) {
param = PROXY_FORWARDED_HOST;
#if 0
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("proto"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("proto"))) {
param = PROXY_FORWARDED_PROTO;
#endif
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("remote_user"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("remote_user"))) {
param = PROXY_FORWARDED_REMOTE_USER;
} else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"extforward.params keys must be one of: host, remote_user, but not:", du->key);
"extforward.params keys must be one of: host, remote_user, but not:", &du->key);
return HANDLER_ERROR;
}
if (du->type == TYPE_STRING) {
@ -317,7 +317,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
s->opts |= param;
} else if (!buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"extforward.params values must be one of: 0, 1, enable, disable; error for key:", du->key);
"extforward.params values must be one of: 0, 1, enable, disable; error for key:", &du->key);
return HANDLER_ERROR;
}
} else if (du->type == TYPE_INTEGER) {
@ -325,7 +325,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
if (di->value) s->opts |= param;
} else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"extforward.params values must be one of: 0, 1, enable, disable; error for key:", du->key);
"extforward.params values must be one of: 0, 1, enable, disable; error for key:", &du->key);
return HANDLER_ERROR;
}
}
@ -1080,7 +1080,7 @@ CONNECTION_FUNC(mod_extforward_handle_request_env) {
* (when mod_extforward is listed after mod_openssl in server.modules)*/
data_string *ds = (data_string *)hctx->env->data[i];
http_header_env_set(con,
CONST_BUF_LEN(ds->key), CONST_BUF_LEN(ds->value));
CONST_BUF_LEN(&ds->key), CONST_BUF_LEN(ds->value));
}
return HANDLER_GO_ON;
}

2
src/mod_magnet.c

@ -254,7 +254,7 @@ static int magnet_array_next(lua_State *L) {
if (pos >= a->used) return 0;
if (NULL != (du = a->data[pos])) {
lua_pushlstring(L, CONST_BUF_LEN(du->key));
lua_pushlstring(L, CONST_BUF_LEN(&du->key));
switch (du->type) {
case TYPE_STRING:
ds = (data_string *)du;

4
src/mod_maxminddb.c

@ -311,7 +311,7 @@ mod_maxmind_geoip2 (array * const env, sock_addr *dst_addr,
for (size_t i = 0, used = pconf->env->used; i < used; ++i) {
if (MMDB_SUCCESS == MMDB_aget_value(entry, &data, cenv[i])
&& data.has_data) {
geoip2_env_set(env, CONST_BUF_LEN(names[i]->key), &data);
geoip2_env_set(env, CONST_BUF_LEN(&names[i]->key), &data);
}
}
}
@ -384,7 +384,7 @@ CONNECTION_FUNC(mod_maxmind_request_env_handler)
* (when mod_extforward is listed after mod_openssl in server.modules)*/
data_string *ds = (data_string *)env->data[i];
http_header_env_set(con,
CONST_BUF_LEN(ds->key), CONST_BUF_LEN(ds->value));
CONST_BUF_LEN(&ds->key), CONST_BUF_LEN(ds->value));
}
return HANDLER_GO_ON;

6
src/mod_openssl.c

@ -744,9 +744,9 @@ network_openssl_ssl_conf_cmd (server *srv, plugin_config *s)
for (size_t i = 0; i < s->ssl_conf_cmd->used; ++i) {
ds = (data_string *)s->ssl_conf_cmd->data[i];
ERR_clear_error();
if (SSL_CONF_cmd(cctx, ds->key->ptr, ds->value->ptr) <= 0) {
if (SSL_CONF_cmd(cctx, ds->key.ptr, ds->value->ptr) <= 0) {
log_error_write(srv, __FILE__, __LINE__, "ssbbss", "SSL:",
"SSL_CONF_cmd", ds->key, ds->value, ":",
"SSL_CONF_cmd", &ds->key, ds->value, ":",
ERR_error_string(ERR_get_error(), NULL));
rc = -1;
break;
@ -1318,7 +1318,7 @@ SETDEFAULTS_FUNC(mod_openssl_set_defaults)
/* inherit ssl settings from global scope (in network_init_ssl())
* (if only ssl.engine = "enable" and no other ssl.* settings)*/
for (size_t j = 0; j < config->value->used; ++j) {
buffer *k = config->value->data[j]->key;
buffer *k = &config->value->data[j]->key;
if (0 == strncmp(k->ptr, "ssl.", sizeof("ssl.")-1)
&& !buffer_is_equal_string(k, CONST_STR_LEN("ssl.engine"))){
log_error_write(srv, __FILE__, __LINE__, "sb",

68
src/mod_proxy.c

@ -178,19 +178,19 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
for (size_t j = 0, used = s->forwarded_params->used; j < used; ++j) {
proxy_forwarded_t param;
du = s->forwarded_params->data[j];
if (buffer_is_equal_string(du->key, CONST_STR_LEN("by"))) {
if (buffer_is_equal_string(&du->key, CONST_STR_LEN("by"))) {
param = PROXY_FORWARDED_BY;
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("for"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("for"))) {
param = PROXY_FORWARDED_FOR;
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("host"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("host"))) {
param = PROXY_FORWARDED_HOST;
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("proto"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("proto"))) {
param = PROXY_FORWARDED_PROTO;
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("remote_user"))) {
} else if (buffer_is_equal_string(&du->key, CONST_STR_LEN("remote_user"))) {
param = PROXY_FORWARDED_REMOTE_USER;
} else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"proxy.forwarded keys must be one of: by, for, host, proto, remote_user, but not:", du->key);
"proxy.forwarded keys must be one of: by, for, host, proto, remote_user, but not:", &du->key);
return HANDLER_ERROR;
}
if (du->type == TYPE_STRING) {
@ -199,7 +199,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
s->forwarded |= param;
} else if (!buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"proxy.forwarded values must be one of: 0, 1, enable, disable; error for key:", du->key);
"proxy.forwarded values must be one of: 0, 1, enable, disable; error for key:", &du->key);
return HANDLER_ERROR;
}
} else if (du->type == TYPE_INTEGER) {
@ -207,7 +207,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
if (di->value) s->forwarded |= param;
} else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"proxy.forwarded values must be one of: 0, 1, enable, disable; error for key:", du->key);
"proxy.forwarded values must be one of: 0, 1, enable, disable; error for key:", &du->key);
return HANDLER_ERROR;
}
}
@ -219,7 +219,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
}
for (size_t j = 0, used = s->header_params->used; j < used; ++j) {
data_array *da = (data_array *)s->header_params->data[j];
if (buffer_is_equal_string(da->key, CONST_STR_LEN("https-remap"))) {
if (buffer_is_equal_string(&da->key, CONST_STR_LEN("https-remap"))) {
data_string *ds = (data_string *)da;
if (ds->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "s",
@ -230,7 +230,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
&& !buffer_is_equal_string(ds->value, CONST_STR_LEN("0"));
continue;
}
else if (buffer_is_equal_string(da->key, CONST_STR_LEN("upgrade"))) {
else if (buffer_is_equal_string(&da->key, CONST_STR_LEN("upgrade"))) {
data_string *ds = (data_string *)da;
if (ds->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "s",
@ -241,7 +241,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
&& !buffer_is_equal_string(ds->value, CONST_STR_LEN("0"));
continue;
}
else if (buffer_is_equal_string(da->key, CONST_STR_LEN("connect"))) {
else if (buffer_is_equal_string(&da->key, CONST_STR_LEN("connect"))) {
data_string *ds = (data_string *)da;
if (ds->type != TYPE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "s",
@ -254,21 +254,21 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
}
if (da->type != TYPE_ARRAY || !array_is_kvstring(da->value)) {