Browse Source

[core] inline buffer as part of data_string value

(instead of value being (buffer *))
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
601c572c39
  1. 18
      src/array.c
  2. 2
      src/array.h
  3. 2
      src/chunk.c
  4. 24
      src/configfile-glue.c
  5. 28
      src/configfile.c
  6. 21
      src/configparser.y
  7. 20
      src/data_string.c
  8. 20
      src/gw_backend.c
  9. 20
      src/http-header-glue.c
  10. 2
      src/http_header.c
  11. 8
      src/mod_alias.c
  12. 8
      src/mod_auth.c
  13. 2
      src/mod_authn_pam.c
  14. 22
      src/mod_authn_sasl.c
  15. 10
      src/mod_cgi.c
  16. 4
      src/mod_cml.c
  17. 16
      src/mod_compress.c
  18. 16
      src/mod_deflate.c
  19. 4
      src/mod_dirlisting.c
  20. 8
      src/mod_evhost.c
  21. 12
      src/mod_expire.c
  22. 36
      src/mod_extforward.c
  23. 10
      src/mod_indexfile.c
  24. 8
      src/mod_magnet.c
  25. 4
      src/mod_maxminddb.c
  26. 8
      src/mod_openssl.c
  27. 42
      src/mod_proxy.c
  28. 4
      src/mod_redirect.c
  29. 4
      src/mod_rewrite.c
  30. 4
      src/mod_scgi.c
  31. 16
      src/mod_setenv.c
  32. 6
      src/mod_ssi.c
  33. 4
      src/mod_ssi_expr.c
  34. 4
      src/mod_trigger_b4_dl.c
  35. 4
      src/mod_userdir.c
  36. 14
      src/mod_vhostdb_dbi.c
  37. 28
      src/mod_vhostdb_ldap.c
  38. 20
      src/mod_vhostdb_mysql.c
  39. 16
      src/mod_vhostdb_pgsql.c
  40. 29
      src/mod_webdav.c
  41. 4
      src/mod_wstunnel.c
  42. 16
      src/plugin.c
  43. 6
      src/response.c
  44. 10
      src/stat_cache.c
  45. 6
      src/t/test_array.c
  46. 14
      src/t/test_request.c

18
src/array.c

@ -69,7 +69,7 @@ void array_reset_data_strings(array * const a) {
data_string * const ds = data[i];
/*force_assert(ds->type == TYPE_STRING);*/
buffer * const k = &ds->key;
buffer * const v = ds->value;
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);
}
@ -247,18 +247,18 @@ int * array_get_int_ptr(array * const a, const char * const k, const size_t klen
buffer * array_get_buf_ptr(array * const a, const char * const k, const size_t klen) {
int32_t ipos = array_get_index(a, k, klen);
if (ipos >= 0) return ((data_string *)a->data[ipos])->value;
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_clear(ds->value);
return ds->value;
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_copy_string_len(ds->value, v, vlen);
buffer_copy_string_len(&ds->value, v, vlen);
}
/* if entry already exists return pointer to existing entry, otherwise insert entry and return NULL */
@ -380,7 +380,7 @@ array_match_value_prefix (const array * const a, const buffer * const b)
const size_t blen = buffer_string_length(b);
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const value = ((data_string *)a->data[i])->value;
const buffer * const value = &((data_string *)a->data[i])->value;
const size_t vlen = buffer_string_length(value);
if (vlen <= blen && 0 == memcmp(b->ptr, value->ptr, vlen))
return value;
@ -394,7 +394,7 @@ array_match_value_prefix_nc (const array * const a, const buffer * const b)
const size_t blen = buffer_string_length(b);
for (uint32_t i = 0; i < a->used; ++i) {
const buffer * const value = ((data_string *)a->data[i])->value;
const buffer * const value = &((data_string *)a->data[i])->value;
const size_t vlen = buffer_string_length(value);
if (vlen <= blen && buffer_eq_icase_ssn(b->ptr, value->ptr, vlen))
return value;
@ -439,7 +439,7 @@ array_match_value_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 value = ((data_string *)a->data[i])->value;
const buffer * const value = &((data_string *)a->data[i])->value;
const size_t vlen = buffer_string_length(value);
if (vlen <= blen && 0 == memcmp(end - vlen, value->ptr, vlen))
return value;
@ -454,7 +454,7 @@ array_match_value_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 value = ((data_string *)a->data[i])->value;
const buffer * const value = &((data_string *)a->data[i])->value;
const size_t vlen = buffer_string_length(value);
if (vlen <= blen && buffer_eq_icase_ssn(end - vlen, value->ptr, vlen))
return value;

2
src/array.h

@ -32,7 +32,7 @@ typedef struct {
typedef struct {
DATA_UNSET;
buffer *value;
buffer value;
} data_string;
data_string *data_string_init(void);

2
src/chunk.c

@ -514,7 +514,7 @@ static chunk *chunkqueue_get_append_tempfile(server *srv, chunkqueue *cq) {
for (errno = EIO; cq->tempdir_idx < cq->tempdirs->used; ++cq->tempdir_idx) {
data_string *ds = (data_string *)cq->tempdirs->data[cq->tempdir_idx];
buffer_copy_buffer(template, ds->value);
buffer_copy_buffer(template, &ds->value);
buffer_append_path_len(template, CONST_STR_LEN("lighttpd-upload-XXXXXX"));
if (-1 != (fd = fdevent_mkstemp_append(template->ptr))) break;
}

24
src/configfile-glue.c

@ -76,7 +76,7 @@ int config_insert_values_internal(server *srv, const array *ca, const config_val
if (du->type == TYPE_STRING) {
const data_string *ds = (const data_string *)du;
buffer_copy_buffer(cv[i].destination, ds->value);
buffer_copy_buffer(cv[i].destination, &ds->value);
} else {
log_error_write(srv, __FILE__, __LINE__, "ss", cv[i].key, "should have been a string like ... = \"...\"");
@ -100,16 +100,16 @@ int config_insert_values_internal(server *srv, const array *ca, const config_val
* short before giving up, in order to support setting numeric
* values with environment variables (eg, port number).
*/
if (ds->value->ptr && *ds->value->ptr) {
if (ds->value.ptr && *ds->value.ptr) {
char *e;
long l = strtol(ds->value->ptr, &e, 10);
if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) {
long l = strtol(ds->value.ptr, &e, 10);
if (e != ds->value.ptr && !*e && l >=0 && l <= 65535) {
*((unsigned short *)(cv[i].destination)) = l;
break;
}
}
log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected a short:", cv[i].key, ds->value);
log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected a short:", cv[i].key, &ds->value);
return -1;
}
@ -129,16 +129,16 @@ int config_insert_values_internal(server *srv, const array *ca, const config_val
case TYPE_STRING: {
const data_string *ds = (const data_string *)du;
if (ds->value->ptr && *ds->value->ptr) {
if (ds->value.ptr && *ds->value.ptr) {
char *e;
long l = strtol(ds->value->ptr, &e, 10);
if (e != ds->value->ptr && !*e && l >= 0) {
long l = strtol(ds->value.ptr, &e, 10);
if (e != ds->value.ptr && !*e && l >= 0) {
*((unsigned int *)(cv[i].destination)) = l;
break;
}
}
log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an integer:", cv[i].key, ds->value);
log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an integer:", cv[i].key, &ds->value);
return -1;
}
@ -151,12 +151,12 @@ int config_insert_values_internal(server *srv, const array *ca, const config_val
if (du->type == TYPE_STRING) {
const data_string *ds = (const data_string *)du;
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("enable"))) {
*((unsigned short *)(cv[i].destination)) = 1;
} else if (buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
} else if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("disable"))) {
*((unsigned short *)(cv[i].destination)) = 0;
} else {
log_error_write(srv, __FILE__, __LINE__, "ssbs", "ERROR: unexpected value for key:", cv[i].key, ds->value, "(enable|disable)");
log_error_write(srv, __FILE__, __LINE__, "ssbs", "ERROR: unexpected value for key:", cv[i].key, &ds->value, "(enable|disable)");
return -1;
}

28
src/configfile.c

@ -35,7 +35,7 @@ static void config_warn_authn_module (server *srv, const char *module, size_t le
const data_unset *du = array_get_element_klen(config->value, CONST_STR_LEN("auth.backend"));
if (NULL != du && du->type == TYPE_STRING) {
data_string *ds = (data_string *)du;
if (buffer_is_equal_string(ds->value, module, len)) {
if (buffer_is_equal_string(&ds->value, module, len)) {
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("mod_authn_"));
buffer_append_string_len(srv->tmp_buf, module, len);
array_insert_value(srv->srvconf.modules, CONST_BUF_LEN(srv->tmp_buf));
@ -78,14 +78,14 @@ static int config_http_parseopts (server *srv, array *a) {
const data_string * const ds = (data_string *)a->data[i];
unsigned short int opt;
int val = 0;
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable")))
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("enable")))
val = 1;
else if (buffer_is_equal_string(ds->value, CONST_STR_LEN("disable")))
else if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("disable")))
val = 0;
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;
}
@ -570,35 +570,35 @@ static int config_insert(server *srv) {
for (i = 0; i < srv->srvconf.modules->used; i++) {
ds = (data_string *)srv->srvconf.modules->data[i];
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_indexfile"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_indexfile"))) {
prepend_mod_indexfile = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_staticfile"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_staticfile"))) {
append_mod_staticfile = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_dirlisting"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_dirlisting"))) {
append_mod_dirlisting = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_openssl"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_openssl"))) {
append_mod_openssl = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_authn_file"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_authn_file"))) {
append_mod_authn_file = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_authn_ldap"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_authn_ldap"))) {
append_mod_authn_ldap = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_authn_mysql"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_authn_mysql"))) {
append_mod_authn_mysql = 0;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_auth"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_auth"))) {
contains_mod_auth = 1;
}
@ -621,7 +621,7 @@ static int config_insert(server *srv) {
for (i = 0; i < srv->srvconf.modules->used; i++) {
ds = (data_string *)srv->srvconf.modules->data[i];
array_insert_value(modules, CONST_BUF_LEN(ds->value));
array_insert_value(modules, CONST_BUF_LEN(&ds->value));
}
array_free(srv->srvconf.modules);
@ -1578,7 +1578,7 @@ int config_set_defaults(server *srv) {
for (i = 0; i < srv->srvconf.upload_tempdirs->used; ++i) {
const data_string * const ds = (data_string *)srv->srvconf.upload_tempdirs->data[i];
buffer_string_set_length(b, len); /*(truncate)*/
buffer_append_string_buffer(b, ds->value);
buffer_append_string_buffer(b, &ds->value);
if (-1 == stat(b->ptr, &st1)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"server.upload-dirs doesn't exist:", b);

21
src/configparser.y

@ -72,12 +72,12 @@ static data_unset *configparser_merge_data(data_unset *op1, const data_unset *op
if (op1->type != op2->type) {
if (op1->type == TYPE_STRING && op2->type == TYPE_INTEGER) {
data_string *ds = (data_string *)op1;
buffer_append_int(ds->value, ((data_integer*)op2)->value);
buffer_append_int(&ds->value, ((data_integer*)op2)->value);
return op1;
} else if (op1->type == TYPE_INTEGER && op2->type == TYPE_STRING) {
data_string *ds = data_string_init();
buffer_append_int(ds->value, ((data_integer*)op1)->value);
buffer_append_string_buffer(ds->value, ((data_string*)op2)->value);
buffer_append_int(&ds->value, ((data_integer*)op1)->value);
buffer_append_string_buffer(&ds->value, &((data_string*)op2)->value);
op1->fn->free(op1);
return (data_unset *)ds;
} else {
@ -89,7 +89,7 @@ static data_unset *configparser_merge_data(data_unset *op1, const data_unset *op
switch (op1->type) {
case TYPE_STRING:
buffer_append_string_buffer(((data_string *)op1)->value, ((data_string *)op2)->value);
buffer_append_string_buffer(&((data_string *)op1)->value, &((data_string *)op2)->value);
break;
case TYPE_INTEGER:
((data_integer *)op1)->value += ((data_integer *)op2)->value;
@ -304,7 +304,7 @@ value(A) ::= key(B). {
if (NULL != (env = getenv(B->ptr + 4))) {
data_string *ds;
ds = data_string_init();
buffer_append_string(ds->value, env);
buffer_append_string(&ds->value, env);
A = (data_unset *)ds;
}
else {
@ -321,12 +321,8 @@ value(A) ::= key(B). {
}
value(A) ::= STRING(B). {
buffer *b;
A = (data_unset *)data_string_init();
b = ((data_string *)(A))->value;
buffer_free(b);
((data_string *)(A))->value = B;
B = NULL;
buffer_copy_buffer(&((data_string *)A)->value, B);
}
value(A) ::= INTEGER(B). {
@ -576,7 +572,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
buffer_append_string_buffer(b, B);
buffer_append_string_buffer(b, C);
buffer_append_string_buffer(b, op);
rvalue = ((data_string*)D)->value;
rvalue = &((data_string*)D)->value;
buffer_append_string_buffer(b, rvalue);
if (NULL != (dc = configparser_get_data_config(ctx->all_configs, CONST_BUF_LEN(b)))) {
@ -764,8 +760,7 @@ stringop(A) ::= expression(B). {
A = NULL;
if (ctx->ok) {
if (B->type == TYPE_STRING) {
A = ((data_string*)B)->value;
((data_string*)B)->value = NULL;
A = buffer_init_buffer(&((data_string*)B)->value);
} else if (B->type == TYPE_INTEGER) {
A = buffer_init();
buffer_copy_int(A, ((data_integer *)B)->value);

20
src/data_string.c

@ -12,7 +12,7 @@ static data_unset *data_string_copy(const data_unset *s) {
data_string *ds = data_string_init();
if (!buffer_is_empty(&src->key)) buffer_copy_buffer(&ds->key, &src->key);
buffer_copy_buffer(ds->value, src->value);
buffer_copy_buffer(&ds->value, &src->value);
return (data_unset *)ds;
}
@ -20,7 +20,7 @@ static void data_string_free(data_unset *d) {
data_string *ds = (data_string *)d;
free(ds->key.ptr);
buffer_free(ds->value);
free(ds->value.ptr);
free(d);
}
@ -30,11 +30,11 @@ static int data_string_insert_dup(data_unset *dst, data_unset *src) {
data_string *ds_dst = (data_string *)dst;
data_string *ds_src = (data_string *)src;
if (!buffer_is_empty(ds_dst->value)) {
buffer_append_string_len(ds_dst->value, CONST_STR_LEN(", "));
buffer_append_string_buffer(ds_dst->value, ds_src->value);
if (!buffer_is_empty(&ds_dst->value)) {
buffer_append_string_len(&ds_dst->value, CONST_STR_LEN(", "));
buffer_append_string_buffer(&ds_dst->value, &ds_src->value);
} else {
buffer_copy_buffer(ds_dst->value, ds_src->value);
buffer_copy_buffer(&ds_dst->value, &ds_src->value);
}
src->fn->free(src);
@ -49,16 +49,16 @@ static void data_string_print(const data_unset *d, int depth) {
UNUSED(depth);
/* empty and uninitialized strings */
if (buffer_string_is_empty(ds->value)) {
if (buffer_string_is_empty(&ds->value)) {
fputs("\"\"", stdout);
return;
}
/* print out the string as is, except prepend " with backslash */
putc('"', stdout);
len = buffer_string_length(ds->value);
len = buffer_string_length(&ds->value);
for (i = 0; i < len; i++) {
unsigned char c = ds->value->ptr[i];
unsigned char c = ds->value.ptr[i];
if (c == '"') {
fputs("\\\"", stdout);
} else {
@ -81,8 +81,6 @@ data_string *data_string_init(void) {
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->value = buffer_init();
ds->type = TYPE_STRING;
ds->fn = &fn;

20
src/gw_backend.c

@ -523,8 +523,8 @@ static int gw_spawn_connection(server *srv, gw_host *host, gw_proc *proc, int de
data_string *ds=(data_string *)host->bin_env_copy->data[i];
char *ge;
if (NULL != (ge = getenv(ds->value->ptr))) {
env_add(&env, CONST_BUF_LEN(ds->value), ge, strlen(ge));
if (NULL != (ge = getenv(ds->value.ptr))) {
env_add(&env,CONST_BUF_LEN(&ds->value),ge,strlen(ge));
}
}
} else {
@ -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) {
@ -1544,13 +1544,13 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const data_unset *du
"unexpected type for x-sendfile-docroot; expected: \"x-sendfile-docroot\" => ( \"/allowed/path\", ... )");
goto error;
}
if (ds->value->ptr[0] != '/') {
if (ds->value.ptr[0] != '/') {
log_error_write(srv, __FILE__, __LINE__, "SBs",
"x-sendfile-docroot paths must begin with '/'; invalid: \"", ds->value, "\"");
"x-sendfile-docroot paths must begin with '/'; invalid: \"", &ds->value, "\"");
goto error;
}
buffer_path_simplify(ds->value, ds->value);
buffer_append_slash(ds->value);
buffer_path_simplify(&ds->value, &ds->value);
buffer_append_slash(&ds->value);
}
}
@ -1591,11 +1591,11 @@ error:
}
int gw_set_defaults_balance(server *srv, gw_plugin_config *s, const data_unset *du) {
buffer *b;
const buffer *b;
if (NULL == du) {
b = NULL;
} else if (du->type == TYPE_STRING) {
b = ((const data_string *)du)->value;
b = &((const data_string *)du)->value;
} else {
log_error_write(srv, __FILE__, __LINE__, "s",
"unexpected type for xxxxx.balance; expected string");
@ -2262,7 +2262,7 @@ handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, in
for (k = 0; k < exts->used; ++k) {
extension = exts->exts[k];
if (buffer_is_equal(ds->value, extension->key)) {
if (buffer_is_equal(&ds->value, extension->key)) {
break;
}
}

20
src/http-header-glue.c

@ -636,11 +636,11 @@ static void http_response_xsendfile (server *srv, connection *con, buffer *path,
size_t i, xlen = buffer_string_length(path);
for (i = 0; i < xdocroot->used; ++i) {
data_string *ds = (data_string *)xdocroot->data[i];
size_t dlen = buffer_string_length(ds->value);
size_t dlen = buffer_string_length(&ds->value);
if (dlen <= xlen
&& (!con->conf.force_lowercase_filenames
? 0 == memcmp(path->ptr, ds->value->ptr, dlen)
: buffer_eq_icase_ssn(path->ptr, ds->value->ptr, dlen))) {
? 0 == memcmp(path->ptr, ds->value.ptr, dlen)
: buffer_eq_icase_ssn(path->ptr, ds->value.ptr, dlen))) {
break;
}
}
@ -710,11 +710,11 @@ static void http_response_xsendfile2(server *srv, connection *con, const buffer
size_t i, xlen = buffer_string_length(b);
for (i = 0; i < xdocroot->used; ++i) {
data_string *ds = (data_string *)xdocroot->data[i];
size_t dlen = buffer_string_length(ds->value);
size_t dlen = buffer_string_length(&ds->value);
if (dlen <= xlen
&& (!con->conf.force_lowercase_filenames
? 0 == memcmp(b->ptr, ds->value->ptr, dlen)
: buffer_eq_icase_ssn(b->ptr, ds->value->ptr, dlen))) {
? 0 == memcmp(b->ptr, ds->value.ptr, dlen)
: buffer_eq_icase_ssn(b->ptr, ds->value.ptr, dlen))) {
break;
}
}
@ -1532,7 +1532,7 @@ 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/ */
@ -1543,7 +1543,7 @@ int http_cgi_headers (server *srv, connection *con, http_cgi_opts *opts, http_cg
buffer_copy_string_encoded_cgi_varnames(srv->tmp_buf,
CONST_BUF_LEN(&ds->key), 1);
rc |= cb(vdata, CONST_BUF_LEN(srv->tmp_buf),
CONST_BUF_LEN(ds->value));
CONST_BUF_LEN(&ds->value));
}
}
@ -1551,11 +1551,11 @@ 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);
rc |= cb(vdata, CONST_BUF_LEN(srv->tmp_buf),
CONST_BUF_LEN(ds->value));
CONST_BUF_LEN(&ds->value));
}
}

2
src/http_header.c

@ -94,7 +94,7 @@ __attribute_pure__
static inline buffer * http_header_generic_get_ifnotempty(const array * const a, const char * const k, const size_t klen) {
data_string * const ds =
(data_string *)array_get_element_klen(a, k, klen);
return ds && !buffer_string_is_empty(ds->value) ? ds->value : NULL;
return ds && !buffer_string_is_empty(&ds->value) ? &ds->value : NULL;
}

8
src/mod_alias.c

@ -184,17 +184,17 @@ PHYSICALPATH_FUNC(mod_alias_physical_handler) {
char *s = uri_ptr + alias_len + 1;
if (*s == '.') ++s;
if (*s == '/' || *s == '\0') {
size_t vlen = buffer_string_length(ds->value);
size_t vlen = buffer_string_length(&ds->value);
if (0 != alias_len && ds->key.ptr[alias_len-1] != '/'
&& 0 != vlen && ds->value->ptr[vlen-1] == '/') {
&& 0 != vlen && ds->value.ptr[vlen-1] == '/') {
con->http_status = 403;
return HANDLER_FINISHED;
}
}
}
buffer_copy_buffer(con->physical.basedir, ds->value);
buffer_copy_buffer(srv->tmp_buf, ds->value);
buffer_copy_buffer(con->physical.basedir, &ds->value);
buffer_copy_buffer(srv->tmp_buf, &ds->value);
buffer_append_string(srv->tmp_buf, uri_ptr + alias_len);
buffer_copy_buffer(con->physical.path, srv->tmp_buf);

8
src/mod_auth.c

@ -342,13 +342,13 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) {
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"))) {
method = ds->value;
method = &ds->value;
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("realm"))) {
realm = ds->value;
realm = &ds->value;
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("require"))) {
require = ds->value;
require = &ds->value;
} else if (buffer_is_equal_string(&ds->key, CONST_STR_LEN("algorithm"))) {
algos = ds->value;
algos = &ds->value;
} else {
log_error_write(srv, __FILE__, __LINE__, "ssbs",
"the field is unknown in:",

2
src/mod_authn_pam.c

@ -91,7 +91,7 @@ SETDEFAULTS_FUNC(mod_authn_pam_set_defaults) {
ds = (const data_string *)
array_get_element_klen(s->opts, CONST_STR_LEN("service"));
s->service = (NULL != ds) ? ds->value->ptr : "http";
s->service = (NULL != ds) ? ds->value.ptr : "http";
}
if (p->config_storage[0]->service == NULL)

22
src/mod_authn_sasl.c

@ -102,11 +102,11 @@ SETDEFAULTS_FUNC(mod_authn_sasl_set_defaults) {
ds = (const data_string *)
array_get_element_klen(s->opts, CONST_STR_LEN("service"));
s->service = (NULL != ds) ? ds->value->ptr : "http";
s->service = (NULL != ds) ? ds->value.ptr : "http";
ds = (const data_string *)
array_get_element_klen(s->opts, CONST_STR_LEN("fqdn"));
if (NULL != ds) s->fqdn = ds->value->ptr;
if (NULL != ds) s->fqdn = ds->value.ptr;
if (NULL == s->fqdn) {
if (NULL == p->fqdn) {
struct utsname uts;
@ -123,25 +123,27 @@ SETDEFAULTS_FUNC(mod_authn_sasl_set_defaults) {
ds = (const data_string *)
array_get_element_klen(s->opts, CONST_STR_LEN("pwcheck_method"));
if (NULL != ds) {
s->pwcheck_method = ds->value;
if (!buffer_is_equal_string(ds->value, CONST_STR_LEN("saslauthd"))
&& !buffer_is_equal_string(ds->value, CONST_STR_LEN("auxprop"))
&& !buffer_is_equal_string(ds->value, CONST_STR_LEN("sasldb"))){
s->pwcheck_method = &ds->value;
if (!buffer_is_equal_string(&ds->value, CONST_STR_LEN("saslauthd"))
&& !buffer_is_equal_string(&ds->value, CONST_STR_LEN("auxprop"))
&& !buffer_is_equal_string(&ds->value, CONST_STR_LEN("sasldb"))){
log_error_write(srv, __FILE__, __LINE__, "sb",
"sasl pwcheck_method must be one of saslauthd, "
"sasldb, or auxprop, not:", ds->value);
"sasldb, or auxprop, not:", &ds->value);
return HANDLER_ERROR;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("sasldb"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("sasldb"))) {
/* Cyrus libsasl2 expects "auxprop" instead of "sasldb"
* (mod_authn_sasl_cb_getopt auxprop_plugin returns "sasldb") */
buffer_copy_string_len(ds->value, CONST_STR_LEN("auxprop"));
buffer *pwcheck_method =
array_get_buf_ptr(s->opts, CONST_STR_LEN("pwcheck_method"));
buffer_copy_string_len(pwcheck_method, CONST_STR_LEN("auxprop"));
}
}
ds = (const data_string *)
array_get_element_klen(s->opts, CONST_STR_LEN("sasldb_path"));
if (NULL != ds) s->sasldb_path = ds->value;
if (NULL != ds) s->sasldb_path = &ds->value;
}
return HANDLER_GO_ON;

10
src/mod_cgi.c

@ -230,13 +230,13 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) {
"unexpected type for key cgi.x-sendfile-docroot; expected: cgi.x-sendfile-docroot = ( \"/allowed/path\", ... )");
return HANDLER_ERROR;
}
if (ds->value->ptr[0] != '/') {
if (ds->value.ptr[0] != '/') {
log_error_write(srv, __FILE__, __LINE__, "SBs",
"cgi.x-sendfile-docroot paths must begin with '/'; invalid: \"", ds->value, "\"");
"cgi.x-sendfile-docroot paths must begin with '/'; invalid: \"", &ds->value, "\"");
return HANDLER_ERROR;
}
buffer_path_simplify(ds->value, ds->value);
buffer_append_slash(ds->value);
buffer_path_simplify(&ds->value, &ds->value);
buffer_append_slash(&ds->value);
}
}
}
@ -927,7 +927,7 @@ URIHANDLER_FUNC(cgi_is_handled) {
handler_ctx *hctx = cgi_handler_ctx_init();
hctx->remote_conn = con;
hctx->plugin_data = p;
hctx->cgi_handler = ds->value;
hctx->cgi_handler = &ds->value;
memcpy(&hctx->conf, &p->conf, sizeof(plugin_config));
hctx->conf.upgrade =
hctx->conf.upgrade

4
src/mod_cml.c

@ -123,14 +123,14 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) {
data_string *ds = (data_string *)s->mc_hosts->data[0];
buffer_append_string_len(option_string, CONST_STR_LEN("--SERVER="));
buffer_append_string_buffer(option_string, ds->value);
buffer_append_string_buffer(option_string, &ds->value);
}
for (k = 1; k < s->mc_hosts->used; k++) {
data_string *ds = (data_string *)s->mc_hosts->data[k];
buffer_append_string_len(option_string, CONST_STR_LEN(" --SERVER="));
buffer_append_string_buffer(option_string, ds->value);
buffer_append_string_buffer(option_string, &ds->value);
}
s->memc = memcached(CONST_BUF_LEN(option_string));

16
src/mod_compress.c

@ -231,21 +231,21 @@ SETDEFAULTS_FUNC(mod_compress_setdefaults) {
data_string *ds = (data_string *)encodings_arr->data[j];
#endif
#ifdef USE_ZLIB
if (NULL != strstr(ds->value->ptr, "gzip"))
if (NULL != strstr(ds->value.ptr, "gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "x-gzip"))
if (NULL != strstr(ds->value.ptr, "x-gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "deflate"))
if (NULL != strstr(ds->value.ptr, "deflate"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
/*
if (NULL != strstr(ds->value->ptr, "compress"))
if (NULL != strstr(ds->value.ptr, "compress"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_COMPRESS;
*/
#endif
#ifdef USE_BZ2LIB
if (NULL != strstr(ds->value->ptr, "bzip2"))
if (NULL != strstr(ds->value.ptr, "bzip2"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2 | HTTP_ACCEPT_ENCODING_X_BZIP2;
if (NULL != strstr(ds->value->ptr, "x-bzip2"))
if (NULL != strstr(ds->value.ptr, "x-bzip2"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_X_BZIP2;
#endif
}
@ -874,8 +874,8 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
for (m = 0; m < p->conf.compress->used; m++) {
data_string *compress_ds = (data_string *)p->conf.compress->data[m];
if (buffer_is_equal(compress_ds->value, sce->content_type)
|| (content_type && buffer_is_equal(compress_ds->value, content_type))) {
if (buffer_is_equal(&compress_ds->value, sce->content_type)
|| (content_type && buffer_is_equal(&compress_ds->value, content_type))) {
/* mimetype found */
buffer *vb;

16
src/mod_deflate.c

@ -346,21 +346,21 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
data_string *ds = (data_string *)p->encodings->data[j];
#endif
#ifdef USE_ZLIB
if (NULL != strstr(ds->value->ptr, "gzip"))
if (NULL != strstr(ds->value.ptr, "gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_GZIP | HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "x-gzip"))
if (NULL != strstr(ds->value.ptr, "x-gzip"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_X_GZIP;
if (NULL != strstr(ds->value->ptr, "deflate"))
if (NULL != strstr(ds->value.ptr, "deflate"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_DEFLATE;
/*
if (NULL != strstr(ds->value->ptr, "compress"))
if (NULL != strstr(ds->value.ptr, "compress"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_COMPRESS;
*/
#endif
#ifdef USE_BZ2LIB
if (NULL != strstr(ds->value->ptr, "bzip2"))
if (NULL != strstr(ds->value.ptr, "bzip2"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_BZIP2 | HTTP_ACCEPT_ENCODING_X_BZIP2;
if (NULL != strstr(ds->value->ptr, "x-bzip2"))
if (NULL != strstr(ds->value.ptr, "x-bzip2"))
s->allowed_encodings |= HTTP_ACCEPT_ENCODING_X_BZIP2;
#endif
}
@ -381,7 +381,7 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
* so ignore '*' at end of mimetype for end-user flexibility
* in specifying trailing wildcard to grouping of mimetypes */
for (size_t m = 0; m < s->mimetypes->used; ++m) {
buffer *mimetype = ((data_string *)s->mimetypes->data[m])->value;
buffer *mimetype = &((data_string *)s->mimetypes->data[m])->value;
size_t len = buffer_string_length(mimetype);
if (len > 2 && mimetype->ptr[len-1] == '*') {
buffer_string_set_length(mimetype, len-1);
@ -1140,7 +1140,7 @@ CONNECTION_FUNC(mod_deflate_handle_response_start) {
} else {
/* If no Content-Type set, compress only if first p->conf.mimetypes value is "" */
data_string *mimetype = (data_string *)p->conf.mimetypes->data[0];
if (!buffer_string_is_empty(mimetype->value)) return HANDLER_GO_ON;
if (!buffer_string_is_empty(&mimetype->value)) return HANDLER_GO_ON;
}
/* Vary: Accept-Encoding (response might change according to request Accept-Encoding) */

4
src/mod_dirlisting.c

@ -304,9 +304,9 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
return HANDLER_ERROR;
}
if (0 != excludes_buffer_append(s->excludes, ((data_string*)(du_exclude))->value)) {
if (0 != excludes_buffer_append(s->excludes, &((data_string*)(du_exclude))->value)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"pcre-compile failed for", ((data_string*)(du_exclude))->value);
"pcre-compile failed for", &((data_string*)(du_exclude))->value);
return HANDLER_ERROR;
}
}

8
src/mod_evhost.c

@ -313,17 +313,17 @@ static void mod_evhost_build_doc_root_path(buffer *b, array *parsed_host, buffer
s[1] = ptr[2]; /*(assumes single digit before '.', and, optionally, '.' and single digit after '.')*/
if (NULL != (ds = (data_string *)array_get_element_klen(parsed_host, s, 2))) {
if (ptr[3] != '.' || ptr[4] == '0') {
buffer_append_string_buffer(b, ds->value);
buffer_append_string_buffer(b, &ds->value);
} else {
if ((size_t)(ptr[4]-'0') <= buffer_string_length(ds->value)) {
buffer_append_string_len(b, ds->value->ptr+(ptr[4]-'0')-1, 1);
if ((size_t)(ptr[4]-'0') <= buffer_string_length(&ds->value)) {
buffer_append_string_len(b, ds->value.ptr+(ptr[4]-'0')-1, 1);
}
}
} else {
/* unhandled %-sequence */
}
} else if (NULL != (ds = (data_string *)array_get_element_klen(parsed_host, CONST_BUF_LEN(path_pieces[i])))) {
buffer_append_string_buffer(b, ds->value);
buffer_append_string_buffer(b, &ds->value);
} else {
/* unhandled %-sequence */
}

12
src/mod_expire.c

@ -255,9 +255,9 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) {
data_string *ds = (data_string *)s->expire_url->data[k];
/* parse lines */
if (-1 == mod_expire_get_offset(srv, p, ds->value, NULL)) {
if (-1 == mod_expire_get_offset(srv, p, &ds->value, NULL)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"parsing expire.url failed:", ds->value);
"parsing expire.url failed:", &ds->value);
return HANDLER_ERROR;
}
}
@ -279,9 +279,9 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) {
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)) {
if (-1 == mod_expire_get_offset(srv, p, &ds->value, NULL)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"parsing expire.mimetypes failed:", ds->value);
"parsing expire.mimetypes failed:", &ds->value);
return HANDLER_ERROR;
}
}
@ -345,7 +345,7 @@ CONNECTION_FUNC(mod_expire_handler) {
/* check expire.url */
ds = (const data_string *)array_match_key_prefix(p->conf.expire_url, con->uri.path);
if (NULL != ds) {
vb = ds->value;
vb = &ds->value;
}
else {
/* check expire.mimetypes (if no match with expire.url) */
@ -354,7 +354,7 @@ CONNECTION_FUNC(mod_expire_handler) {
? (const data_string *)array_match_key_prefix(p->conf.expire_mimetypes, vb)
: (const data_string *)array_get_element_klen(p->conf.expire_mimetypes, CONST_STR_LEN(""));
if (NULL == ds) return HANDLER_GO_ON;
vb = ds->value;
vb = &ds->value;
}
if (NULL != vb) {

36
src/mod_extforward.c

@ -228,18 +228,18 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
if (array_get_element_klen(config->value, CONST_STR_LEN("extforward.forwarder"))) {
const data_string * const allds = (const data_string *)array_get_element_klen(s->forwarder, CONST_STR_LEN("all"));
s->forward_all = (NULL == allds) ? 0 : buffer_eq_icase_slen(allds->value, CONST_STR_LEN("trust")) ? 1 : -1;
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, '/');
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");
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");
}
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 */
buffer_clear(&ds->value); /* empty is untrusted */
continue;
}
if (NULL != nm_slash) {
@ -266,7 +266,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
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 */
buffer_clear(&ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */
}
}
}
@ -313,9 +313,9 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
}
if (du->type == TYPE_STRING) {
data_string *ds = (data_string *)du;
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("enable"))) {
s->opts |= param;
} else if (!buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
} 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);
return HANDLER_ERROR;
@ -344,13 +344,13 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
size_t j;
for (j = 0; j < srv->srvconf.modules->used; ++j) {
data_string *ds = (data_string *)srv->srvconf.modules->data[j];
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_extforward"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_extforward"))) {
break;
}
}
for (; j < srv->srvconf.modules->used; ++j) {
data_string *ds = (data_string *)srv->srvconf.modules->data[j];
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_openssl"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_openssl"))) {
log_error_write(srv, __FILE__, __LINE__, "s",
"mod_extforward must be loaded after mod_openssl in server.modules when extforward.hap-PROXY = \"enable\"");
break;
@ -362,7 +362,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
for (i = 0; i < srv->srvconf.modules->used; i++) {
data_string *ds = (data_string *)srv->srvconf.modules->data[i];
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("mod_proxy"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("mod_proxy"))) {
extforward_check_proxy = 1;
break;
}
@ -460,7 +460,7 @@ static int is_proxy_trusted(plugin_data *p, const char * const ip, size_t iplen)
{
const data_string *ds =
(const data_string *)array_get_element_klen(p->conf.forwarder, ip, iplen);
if (NULL != ds) return !buffer_string_is_empty(ds->value);
if (NULL != ds) return !buffer_string_is_empty(&ds->value);
if (p->conf.forward_masks) {
const struct sock_addr_mask * const addrs =p->conf.forward_masks->addrs;
@ -500,8 +500,8 @@ static const char *last_not_in_array(array *a, plugin_data *p)
for (i = a->used - 1; i >= 0; i--) {
data_string *ds = (data_string *)a->data[i];
if (!is_proxy_trusted(p, CONST_BUF_LEN(ds->value))) {
return ds->value->ptr;
if (!is_proxy_trusted(p, CONST_BUF_LEN(&ds->value))) {
return ds->value.ptr;
}
}
return NULL;
@ -1025,7 +1025,7 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) {
CONST_STR_LEN("SUCCESS"));
http_header_env_set(con,
CONST_STR_LEN("REMOTE_USER"),
CONST_BUF_LEN(ds->value));
CONST_BUF_LEN(&ds->value));
http_header_env_set(con,
CONST_STR_LEN("AUTH_TYPE"),
CONST_STR_LEN("SSL_CLIENT_VERIFY"));
@ -1037,7 +1037,7 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) {
}
for (size_t k = 0; k < p->conf.headers->used && NULL == forwarded; ++k) {
buffer *hdr = ((data_string *)p->conf.headers->data[k])->value;
buffer *hdr = &((data_string *)p->conf.headers->data[k])->value;
forwarded = http_header_request_get(con, HTTP_HEADER_UNSPECIFIED, CONST_BUF_LEN(hdr));
if (forwarded) {
is_forwarded_header = buffer_is_equal_caseless_string(hdr, CONST_STR_LEN("Forwarded"));
@ -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;
}

10
src/mod_indexfile.c

@ -164,14 +164,14 @@ URIHANDLER_FUNC(mod_indexfile_subrequest) {
for (k = 0; k < p->conf.indexfiles->used; k++) {
data_string *ds = (data_string *)p->conf.indexfiles->data[k];
if (ds->value && ds->value->ptr[0] == '/') {
if (ds->value.ptr[0] == '/') {
/* if the index-file starts with a prefix as use this file as
* index-generator */
buffer_copy_buffer(p->tmp_buf, con->physical.doc_root);
} else {
buffer_copy_buffer(p->tmp_buf, con->physical.path);
}
buffer_append_string_buffer(p->tmp_buf, ds->value);
buffer_append_string_buffer(p->tmp_buf, &ds->value);
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, p->tmp_buf, &sce)) {
if (errno == EACCES) {
@ -199,13 +199,13 @@ URIHANDLER_FUNC(mod_indexfile_subrequest) {
continue;
}
if (ds->value && ds->value->ptr[0] == '/') {
if (ds->value.ptr[0] == '/') {
/* replace uri.path */
buffer_copy_buffer(con->uri.path, ds->value);
buffer_copy_buffer(con->uri.path, &ds->value);
http_header_env_set(con, CONST_STR_LEN("PATH_TRANSLATED_DIRINDEX"), CONST_BUF_LEN(con->physical.path));
} else {
/* append to uri.path the relative path to index file (/ -> /index.php) */
buffer_append_string_buffer(con->uri.path, ds->value);
buffer_append_string_buffer(con->uri.path, &ds->value);
}
buffer_copy_buffer(con->physical.path, p->tmp_buf);

8
src/mod_magnet.c

@ -236,7 +236,7 @@ static int magnet_array_get_element(lua_State *L, const array *a) {
const char * const k = luaL_checklstring(L, 2, &klen);
const data_string * const ds = (const data_string *)
array_get_element_klen(a, k, klen);
magnet_push_buffer(L, NULL != ds ? ds->value : NULL);
magnet_push_buffer(L, NULL != ds ? &ds->value : NULL);
return 1;
}
#endif
@ -258,7 +258,7 @@ static int magnet_array_next(lua_State *L) {
switch (du->type) {
case TYPE_STRING:
ds = (data_string *)du;
magnet_push_buffer(L, ds->value);
magnet_push_buffer(L, &ds->value);
break;
case TYPE_INTEGER:
di = (data_integer *)du;
@ -1064,9 +1064,9 @@ static handler_t magnet_attract_array(server *srv, connection *con, plugin_data
for (i = 0; i < files->used && ret == HANDLER_GO_ON; i++) {
data_string *ds = (data_string *)files->data[i];
if (buffer_string_is_empty(ds->value)) continue;
if (buffer_string_is_empty(&ds->value)) continue;
ret = magnet_attract(srv, con, p, ds->value);
ret = magnet_attract(srv, con, p, &ds->value);
}
if (con->error_handler_saved_status) {

4
src/mod_maxminddb.c

@ -204,7 +204,7 @@ SETDEFAULTS_FUNC(mod_maxmind_set_defaults)
"maxminddb.env must be a list of strings");
return HANDLER_ERROR;
}
buffer *value = data[j]->value;
buffer *value = &data[j]->value;
if (buffer_string_is_empty(value)
|| '/' == value->ptr[0]
|| '/' == value->ptr[buffer_string_length(value)-1]) {
@ -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;

8
src/mod_openssl.c

@ -737,16 +737,18 @@ network_openssl_ssl_conf_cmd (server *srv, plugin_config *s)
array_get_element_klen(s->ssl_conf_cmd,
CONST_STR_LEN("CipherString"));
if (NULL != ds) {
buffer_append_string_len(ds->value,
buffer *cipher_string =
array_get_buf_ptr(s->ssl_conf_cmd, CONST_STR_LEN("CipherString"));
buffer_append_string_len(cipher_string,
CONST_STR_LEN(":!aNULL:!eNULL:!EXP"));
}
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;

42
src/mod_proxy.c

@ -195,9 +195,9 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
}
if (du->type == TYPE_STRING) {
data_string *ds = (data_string *)du;
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable"))) {
if (buffer_is_equal_string(&ds->value, CONST_STR_LEN("enable"))) {
s->forwarded |= param;
} else if (!buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
} 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);
return HANDLER_ERROR;
@ -226,8 +226,8 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
"unexpected value for proxy.header; expected \"enable\" or \"disable\" for https-remap");
return HANDLER_ERROR;
}
s->header.https_remap = !buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))
&& !buffer_is_equal_string(ds->value, CONST_STR_LEN("0"));
s->header.https_remap = !buffer_is_equal_string(&ds->value, CONST_STR_LEN("disable"))
&& !buffer_is_equal_string(&ds->value, CONST_STR_LEN("0"));
continue;
}
else if (buffer_is_equal_string(&da->key, CONST_STR_LEN("upgrade"))) {
@ -237,8 +237,8 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) {
"unexpected value for proxy.header; expected \"upgrade\" => \"enable\" or \"disable\"");
return HANDLER_ERROR;
<