diff options
-rw-r--r-- | src/array.c | 14 | ||||
-rw-r--r-- | src/array.h | 5 | ||||
-rw-r--r-- | src/configfile-glue.c | 6 | ||||
-rw-r--r-- | src/configfile.c | 2 | ||||
-rw-r--r-- | src/configparser.y | 18 | ||||
-rw-r--r-- | src/data_config.c | 2 | ||||
-rw-r--r-- | src/http-header-glue.c | 6 | ||||
-rw-r--r-- | src/mod_accesslog.c | 6 | ||||
-rw-r--r-- | src/mod_evhost.c | 4 | ||||
-rw-r--r-- | src/mod_extforward.c | 25 | ||||
-rw-r--r-- | src/mod_fastcgi.c | 2 | ||||
-rw-r--r-- | src/mod_magnet.c | 10 | ||||
-rw-r--r-- | src/mod_openssl.c | 4 | ||||
-rw-r--r-- | src/mod_proxy.c | 2 | ||||
-rw-r--r-- | src/mod_rewrite.c | 20 | ||||
-rw-r--r-- | src/mod_scgi.c | 2 | ||||
-rw-r--r-- | src/mod_ssi.c | 4 | ||||
-rw-r--r-- | src/mod_ssi_expr.c | 4 | ||||
-rw-r--r-- | src/request.c | 8 | ||||
-rw-r--r-- | src/server.c | 2 | ||||
-rw-r--r-- | src/stat_cache.c | 6 | ||||
-rw-r--r-- | src/status_counter.c | 2 |
22 files changed, 72 insertions, 82 deletions
diff --git a/src/array.c b/src/array.c index ee2f0dd1..6e93c017 100644 --- a/src/array.c +++ b/src/array.c @@ -120,11 +120,11 @@ static size_t array_get_index(array *a, const char *key, size_t keylen, size_t * return ARRAY_NOT_FOUND; } -data_unset *array_get_element(array *a, const char *key) { +data_unset *array_get_element_klen(array *a, const char *key, size_t klen) { size_t ndx; force_assert(NULL != key); - if (ARRAY_NOT_FOUND != (ndx = array_get_index(a, key, strlen(key), NULL))) { + if (ARRAY_NOT_FOUND != (ndx = array_get_index(a, key, klen, NULL))) { /* found, return it */ return a->data[ndx]; } @@ -132,11 +132,11 @@ data_unset *array_get_element(array *a, const char *key) { return NULL; } -data_unset *array_extract_element(array *a, const char *key) { +data_unset *array_extract_element_klen(array *a, const char *key, size_t klen) { size_t ndx, pos; force_assert(NULL != key); - if (ARRAY_NOT_FOUND != (ndx = array_get_index(a, key, strlen(key), &pos))) { + if (ARRAY_NOT_FOUND != (ndx = array_get_index(a, key, klen, &pos))) { /* found */ const size_t last_ndx = a->used - 1; data_unset *entry = a->data[ndx]; @@ -193,7 +193,7 @@ data_unset *array_get_unused_element(array *a, data_type_t t) { void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len) { data_string *ds_dst; - if (NULL != (ds_dst = (data_string *)array_get_element(hdrs, key))) { + if (NULL != (ds_dst = (data_string *)array_get_element_klen(hdrs, key, key_len))) { buffer_copy_string_len(ds_dst->value, value, val_len); return; } @@ -330,7 +330,7 @@ size_t array_get_max_key_length(array *a) { maxlen = 0; for (i = 0; i < a->used; i ++) { data_unset *du = a->data[i]; - size_t len = strlen(du->key->ptr); + size_t len = buffer_string_length(du->key); if (len > maxlen) { maxlen = len; @@ -388,7 +388,7 @@ int array_print(array *a, int depth) { array_print_indent(depth + 1); } fprintf(stdout, "\"%s\"", du->key->ptr); - for (j = maxlen - strlen(du->key->ptr); j > 0; j --) { + for (j = maxlen - buffer_string_length(du->key); j > 0; j--) { fprintf(stdout, " "); } fprintf(stdout, " => "); diff --git a/src/array.h b/src/array.h index 81a6d8ca..b8f6112c 100644 --- a/src/array.h +++ b/src/array.h @@ -163,8 +163,9 @@ int array_is_kvarray(array *a); int array_is_kvstring(array *a); int array_print(array *a, int depth); data_unset *array_get_unused_element(array *a, data_type_t t); -data_unset *array_get_element(array *a, const char *key); -data_unset *array_extract_element(array *a, const char *key); /* removes found entry from array */ +#define array_get_element(a, key) array_get_element_klen((a), (key), sizeof(key)-1) +data_unset *array_get_element_klen(array *a, const char *key, size_t klen); +data_unset *array_extract_element_klen(array *a, const char *key, size_t klen); /* removes found entry from array */ void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len); void array_replace(array *a, data_unset *entry); int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len); diff --git a/src/configfile-glue.c b/src/configfile-glue.c index c8e58323..c8cc88ba 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -35,7 +35,7 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t for (i = 0; cv[i].key; i++) { - if (NULL == (du = array_get_element(ca, cv[i].key))) { + if (NULL == (du = array_get_element_klen(ca, cv[i].key, strlen(cv[i].key)))) { /* no found */ continue; @@ -195,7 +195,7 @@ int config_insert_values_global(server *srv, array *ca, const config_values_t cv for (i = 0; cv[i].key; i++) { data_string *touched; - if (NULL == (du = array_get_element(ca, cv[i].key))) { + if (NULL == (du = array_get_element_klen(ca, cv[i].key, strlen(cv[i].key)))) { /* no found */ continue; @@ -491,7 +491,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat case COMP_HTTP_REQUEST_HEADER: { data_string *ds; - if (NULL != (ds = (data_string *)array_get_element(con->request.headers, dc->comp_tag->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->request.headers, CONST_BUF_LEN(dc->comp_tag)))) { l = ds->value; } else { l = srv->empty_string; diff --git a/src/configfile.c b/src/configfile.c index dbf01234..23442b0c 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -1347,7 +1347,7 @@ int config_read(server *srv, const char *fn) { dcwd = data_string_init(); buffer_string_prepare_copy(dcwd->value, 1023); if (NULL != getcwd(dcwd->value->ptr, dcwd->value->size - 1)) { - buffer_commit(dcwd->value, strlen(dcwd->value->ptr)); + buffer_commit(dcwd->value, buffer_string_length(dcwd->value)); buffer_copy_string_len(dcwd->key, CONST_STR_LEN("var.CWD")); array_insert_unique(dc->value, (data_unset *)dcwd); } else { diff --git a/src/configparser.y b/src/configparser.y index ad8b8ce9..a8b54237 100644 --- a/src/configparser.y +++ b/src/configparser.y @@ -49,7 +49,7 @@ static data_unset *configparser_get_variable(config_t *ctx, const buffer *key) { fprintf(stderr, "get var on block: %s\n", dc->key->ptr); array_print(dc->value, 0); #endif - if (NULL != (du = array_get_element(dc->value, key->ptr))) { + if (NULL != (du = array_get_element_klen(dc->value, CONST_BUF_LEN(key)))) { return du->copy(du); } } @@ -95,7 +95,7 @@ data_unset *configparser_merge_data(data_unset *op1, const data_unset *op2) { for (i = 0; i < src->used; i ++) { du = (data_unset *)src->data[i]; if (du) { - if (du->is_index_key || buffer_is_empty(du->key) || !array_get_element(dst, du->key->ptr)) { + if (du->is_index_key || buffer_is_empty(du->key) || !array_get_element_klen(dst, CONST_BUF_LEN(du->key))) { array_insert_unique(dst, du->copy(du)); } else { fprintf(stderr, "Duplicate array-key '%s'\n", du->key->ptr); @@ -189,7 +189,7 @@ varline ::= key(A) ASSIGN expression(B). { ctx->current->context_ndx, ctx->current->key->ptr, A->ptr); ctx->ok = 0; - } else if (NULL == array_get_element(ctx->current->value, B->key->ptr)) { + } 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 { @@ -234,7 +234,7 @@ varline ::= key(A) APPEND expression(B). { ctx->current->context_ndx, ctx->current->key->ptr, A->ptr); ctx->ok = 0; - } else if (NULL != (du = array_extract_element(vars, A->ptr)) || NULL != (du = configparser_get_variable(ctx, A))) { + } 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); if (NULL == du) { ctx->ok = 0; @@ -351,7 +351,7 @@ aelements(A) ::= aelements(C) COMMA aelement(B). { A = NULL; if (ctx->ok) { if (buffer_is_empty(B->key) || - NULL == array_get_element(C, B->key->ptr)) { + NULL == array_get_element_klen(C, CONST_BUF_LEN(B->key))) { array_insert_unique(C, B); B = NULL; } else { @@ -408,7 +408,7 @@ eols ::= . globalstart ::= GLOBAL. { data_config *dc; - dc = (data_config *)array_get_element(ctx->srv->config_context, "global"); + dc = (data_config *)array_get_element_klen(ctx->srv->config_context, CONST_STR_LEN("global")); force_assert(dc); configparser_push(ctx, dc, 0); } @@ -453,7 +453,7 @@ condlines(A) ::= condlines(B) eols ELSE cond_else(C). { if (ctx->ok) { size_t pos; data_config *dc; - dc = (data_config *)array_extract_element(ctx->all_configs, C->key->ptr); + 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->comp_key, B->comp_key);*/ @@ -480,7 +480,7 @@ condlines(A) ::= condlines(B) eols ELSE cond_else(C). { force_assert(0); } - if (NULL == (dc = (data_config *)array_get_element(ctx->all_configs, C->key->ptr))) { + if (NULL == (dc = (data_config *)array_get_element_klen(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; @@ -568,7 +568,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio rvalue = ((data_string*)D)->value; buffer_append_string_buffer(b, rvalue); - if (NULL != (dc = (data_config *)array_get_element(ctx->all_configs, b->ptr))) { + if (NULL != (dc = (data_config *)array_get_element_klen(ctx->all_configs, CONST_BUF_LEN(b)))) { configparser_push(ctx, dc, 0); } else { static const struct { diff --git a/src/data_config.c b/src/data_config.c index 99ae7307..3fcd2685 100644 --- a/src/data_config.c +++ b/src/data_config.c @@ -81,7 +81,7 @@ 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 = strlen(du->key->ptr); + size_t len = buffer_string_length(du->key); size_t j; array_print_indent(depth); diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 76b61199..09f930c9 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -106,8 +106,8 @@ int response_header_overwrite(server *srv, connection *con, const char *key, siz UNUSED(srv); /* if there already is a key by this name overwrite the value */ - if (NULL != (ds = (data_string *)array_get_element(con->response.headers, key))) { - buffer_copy_string(ds->value, value); + if (NULL != (ds = (data_string *)array_get_element_klen(con->response.headers, key, keylen))) { + buffer_copy_string_len(ds->value, value, vallen); return 0; } @@ -121,7 +121,7 @@ int response_header_append(server *srv, connection *con, const char *key, size_t UNUSED(srv); /* if there already is a key by this name append the value */ - if (NULL != (ds = (data_string *)array_get_element(con->response.headers, key))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->response.headers, key, keylen))) { buffer_append_string_len(ds->value, CONST_STR_LEN(", ")); buffer_append_string_len(ds->value, value, vallen); return 0; diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c index 34aedc36..fbd3da25 100644 --- a/src/mod_accesslog.c +++ b/src/mod_accesslog.c @@ -927,14 +927,14 @@ REQUESTDONE_FUNC(log_access_write) { } break; case FORMAT_HEADER: - if (NULL != (ds = (data_string *)array_get_element(con->request.headers, f->string->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->request.headers, CONST_BUF_LEN(f->string)))) { accesslog_append_escaped(b, ds->value); } else { buffer_append_string_len(b, CONST_STR_LEN("-")); } break; case FORMAT_RESPONSE_HEADER: - if (NULL != (ds = (data_string *)array_get_element(con->response.headers, f->string->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->response.headers, CONST_BUF_LEN(f->string)))) { accesslog_append_escaped(b, ds->value); } else { buffer_append_string_len(b, CONST_STR_LEN("-")); @@ -942,7 +942,7 @@ REQUESTDONE_FUNC(log_access_write) { break; case FORMAT_ENV: case FORMAT_NOTE: - if (NULL != (ds = (data_string *)array_get_element(con->environment, f->string->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->environment, CONST_BUF_LEN(f->string)))) { accesslog_append_escaped(b, ds->value); } else { buffer_append_string_len(b, CONST_STR_LEN("-")); diff --git a/src/mod_evhost.c b/src/mod_evhost.c index 0a8cfbc4..e669b3cc 100644 --- a/src/mod_evhost.c +++ b/src/mod_evhost.c @@ -328,7 +328,7 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d) } else if (ptr[1] == '{' ) { char s[3] = "% "; s[1] = ptr[2]; /*(assumes single digit before '.', and, optionally, '.' and single digit after '.')*/ - if (NULL != (ds = (data_string *)array_get_element(parsed_host, s))) { + if (NULL != (ds = (data_string *)array_get_element_klen(parsed_host, s, 2))) { if (ptr[3] != '.' || ptr[4] == '0') { buffer_append_string_buffer(p->tmp_buf, ds->value); } else { @@ -339,7 +339,7 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d) } else { /* unhandled %-sequence */ } - } else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) { + } else if (NULL != (ds = (data_string *)array_get_element_klen(parsed_host, CONST_BUF_LEN(p->conf.path_pieces[i])))) { buffer_append_string_buffer(p->tmp_buf,ds->value); } else { /* unhandled %-sequence */ diff --git a/src/mod_extforward.c b/src/mod_extforward.c index 10c05457..2020a4e8 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -399,7 +399,7 @@ static array *extract_forward_array(buffer *pbuffer) /* * check whether ip is trusted, return 1 for trusted , 0 for untrusted */ -static int is_proxy_trusted(const char *ipstr, plugin_data *p) +static int is_proxy_trusted(const buffer *ipstr, plugin_data *p) { data_string* allds = (data_string *)array_get_element(p->conf.forwarder, "all"); @@ -411,11 +411,11 @@ static int is_proxy_trusted(const char *ipstr, plugin_data *p) } } - return (data_string *)array_get_element(p->conf.forwarder, ipstr) ? IP_TRUSTED : IP_UNTRUSTED; + return (data_string *)array_get_element_klen(p->conf.forwarder, CONST_BUF_LEN(ipstr)) ? IP_TRUSTED : IP_UNTRUSTED; } /* - * Return char *ip of last address of proxy that is not trusted. + * Return last address of proxy that is not trusted. * Do not accept "all" keyword here. */ static const char *last_not_in_array(array *a, plugin_data *p) @@ -425,10 +425,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]; - const char *ip = ds->value->ptr; - - if (!array_get_element(forwarder, ip)) { - return ip; + if (!array_get_element_klen(forwarder, CONST_BUF_LEN(ds->value))) { + return ds->value->ptr; } } return NULL; @@ -756,12 +754,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_ * attempted by this module. */ if (v != vlen) { - char *ipend = s+vlen; - int trusted; - char c = *ipend; - *ipend = '\0'; - trusted = (NULL != array_get_element(p->conf.forwarder, s+v)); - *ipend = c; + int trusted = (NULL != array_get_element_klen(p->conf.forwarder, s+v, vlen-v)); if (s[v] != '_' && s[v] != '/' && (7 != (vlen - v) || 0 != memcmp(s+v, "unknown", 7))) { @@ -1029,7 +1022,7 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) { } for (size_t k = 0; k < p->conf.headers->used && NULL == forwarded; ++k) { - forwarded = (data_string *) array_get_element(con->request.headers, ((data_string *)p->conf.headers->data[k])->value->ptr); + forwarded = (data_string *) array_get_element_klen(con->request.headers, CONST_BUF_LEN(((data_string *)p->conf.headers->data[k])->value)); } if (NULL == forwarded) { if (con->conf.log_request_handling) { @@ -1040,7 +1033,7 @@ URIHANDLER_FUNC(mod_extforward_uri_handler) { } /* if the remote ip itself is not trusted, then do nothing */ - if (IP_UNTRUSTED == is_proxy_trusted(con->dst_addr_buf->ptr, p)) { + if (IP_UNTRUSTED == is_proxy_trusted(con->dst_addr_buf, p)) { if (con->conf.log_request_handling) { log_error_write(srv, __FILE__, __LINE__, "sbs", "remote address", con->dst_addr_buf, "is NOT a trusted proxy, skipping"); @@ -1134,7 +1127,7 @@ CONNECTION_FUNC(mod_extforward_handle_con_accept) plugin_data *p = p_d; mod_extforward_patch_connection(srv, con, p); if (!p->conf.hap_PROXY) return HANDLER_GO_ON; - if (IP_TRUSTED == is_proxy_trusted(con->dst_addr_buf->ptr, p)) { + if (IP_TRUSTED == is_proxy_trusted(con->dst_addr_buf, p)) { handler_ctx *hctx = handler_ctx_init(); con->plugin_ctx[p->id] = hctx; hctx->saved_network_read = con->network_read; diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index 37f8dffe..a5cd87bf 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -3051,7 +3051,7 @@ static handler_t fcgi_check_extension(server *srv, connection *con, void *p_d, i /* the rewrite is only done for /prefix/? matches */ if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') { - buffer_copy_string(con->request.pathinfo, con->uri.path->ptr); + buffer_copy_buffer(con->request.pathinfo, con->uri.path); buffer_string_set_length(con->uri.path, 0); } else if (extension->key->ptr[0] == '/' && buffer_string_length(con->uri.path) > buffer_string_length(extension->key) && diff --git a/src/mod_magnet.c b/src/mod_magnet.c index b460f3c7..5ca56755 100644 --- a/src/mod_magnet.c +++ b/src/mod_magnet.c @@ -425,9 +425,10 @@ static int magnet_reqhdr_get(lua_State *L) { data_string *ds; /* __index: param 1 is the (empty) table the value was not found in */ - const char *key = luaL_checkstring(L, 2); + size_t klen; + const char *key = luaL_checklstring(L, 2, &klen); - if (NULL != (ds = (data_string *)array_get_element(con->request.headers, key))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->request.headers, key, klen))) { if (!buffer_is_empty(ds->value)) { lua_pushlstring(L, CONST_BUF_LEN(ds->value)); } else { @@ -661,9 +662,10 @@ static int magnet_cgi_get(lua_State *L) { data_string *ds; /* __index: param 1 is the (empty) table the value was not found in */ - const char *key = luaL_checkstring(L, 2); + size_t klen; + const char *key = luaL_checklstring(L, 2, &klen); - ds = (data_string *)array_get_element(con->environment, key); + ds = (data_string *)array_get_element_klen(con->environment, key, klen); if (NULL != ds && !buffer_is_empty(ds->value)) lua_pushlstring(L, CONST_BUF_LEN(ds->value)); else diff --git a/src/mod_openssl.c b/src/mod_openssl.c index 39559e66..3a8ec9cb 100644 --- a/src/mod_openssl.c +++ b/src/mod_openssl.c @@ -1428,8 +1428,8 @@ https_add_ssl_client_entries (server *srv, connection *con, handler_ctx *hctx) * ssl.verifyclient.username = "SSL_CLIENT_S_DN_emailAddress" */ data_string *ds = (data_string *) - array_get_element(con->environment, - hctx->conf.ssl_verifyclient_username->ptr); + array_get_element_klen(con->environment, + CONST_BUF_LEN(hctx->conf.ssl_verifyclient_username)); if (ds) { /* same as http_auth.c:http_auth_setenv() */ array_set_key_value(con->environment, CONST_STR_LEN("REMOTE_USER"), diff --git a/src/mod_proxy.c b/src/mod_proxy.c index 8821e981..a6a62bbf 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -423,7 +423,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) { /* if extension already exists, take it */ - if (NULL == (dfa = (data_array *)array_get_element(s->extensions, da_ext->key->ptr))) { + if (NULL == (dfa = (data_array *)array_get_element_klen(s->extensions, CONST_BUF_LEN(da_ext->key)))) { dfa = data_array_init(); buffer_copy_buffer(dfa->key, da_ext->key); diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c index 7ed56f8d..994a5dae 100644 --- a/src/mod_rewrite.c +++ b/src/mod_rewrite.c @@ -164,10 +164,10 @@ FREE_FUNC(mod_rewrite_free) { return HANDLER_GO_ON; } -static int parse_config_entry(server *srv, array *ca, rewrite_rule_buffer *kvb, const char *option, int once) { +static int parse_config_entry(server *srv, array *ca, rewrite_rule_buffer *kvb, const char *option, size_t olen, int once) { data_unset *du; - if (NULL != (du = array_get_element(ca, option))) { + if (NULL != (du = array_get_element_klen(ca, option, olen))) { data_array *da; size_t j; @@ -194,10 +194,10 @@ static int parse_config_entry(server *srv, array *ca, rewrite_rule_buffer *kvb, return 0; } #else -static int parse_config_entry(server *srv, array *ca, const char *option) { +static int parse_config_entry(server *srv, array *ca, const char *option, size_t olen) { static int logged_message = 0; if (logged_message) return 0; - if (NULL != array_get_element(ca, option)) { + if (NULL != array_get_element_klen(ca, option, olen)) { logged_message = 1; log_error_write(srv, __FILE__, __LINE__, "s", "pcre support is missing, please install libpcre and the headers"); @@ -261,12 +261,12 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { #ifndef HAVE_PCRE_H # define parse_config_entry(srv, ca, x, option, y) parse_config_entry(srv, ca, option) #endif - parse_config_entry(srv, config->value, s->rewrite, "url.rewrite-once", 1); - parse_config_entry(srv, config->value, s->rewrite, "url.rewrite-final", 1); - parse_config_entry(srv, config->value, s->rewrite_NF, "url.rewrite-if-not-file", 1); - parse_config_entry(srv, config->value, s->rewrite_NF, "url.rewrite-repeat-if-not-file", 0); - parse_config_entry(srv, config->value, s->rewrite, "url.rewrite", 1); - parse_config_entry(srv, config->value, s->rewrite, "url.rewrite-repeat", 0); + parse_config_entry(srv, config->value, s->rewrite, CONST_STR_LEN("url.rewrite-once"), 1); + parse_config_entry(srv, config->value, s->rewrite, CONST_STR_LEN("url.rewrite-final"), 1); + parse_config_entry(srv, config->value, s->rewrite_NF, CONST_STR_LEN("url.rewrite-if-not-file"), 1); + parse_config_entry(srv, config->value, s->rewrite_NF, CONST_STR_LEN("url.rewrite-repeat-if-not-file"), 0); + parse_config_entry(srv, config->value, s->rewrite, CONST_STR_LEN("url.rewrite"), 1); + parse_config_entry(srv, config->value, s->rewrite, CONST_STR_LEN("url.rewrite-repeat"), 0); } return HANDLER_GO_ON; diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 77eb4002..d7bdf287 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -2440,7 +2440,7 @@ static handler_t scgi_check_extension(server *srv, connection *con, void *p_d, i /* the rewrite is only done for /prefix/? matches */ if (host->fix_root_path_name && extension->key->ptr[0] == '/' && extension->key->ptr[1] == '\0') { - buffer_copy_string(con->request.pathinfo, con->uri.path->ptr); + buffer_copy_buffer(con->request.pathinfo, con->uri.path); buffer_string_set_length(con->uri.path, 0); } else if (extension->key->ptr[0] == '/' && buffer_string_length(con->uri.path) > buffer_string_length(extension->key) && diff --git a/src/mod_ssi.c b/src/mod_ssi.c index 3842bbe9..d0c6bfab 100644 --- a/src/mod_ssi.c +++ b/src/mod_ssi.c @@ -465,8 +465,8 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const data_string *ds; /* check if it is a cgi-var or a ssi-var */ - if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, var_val)) || - NULL != (ds = (data_string *)array_get_element(p->ssi_vars, var_val))) { + if (NULL != (ds = (data_string *)array_get_element_klen(p->ssi_cgi_env, var_val, strlen(var_val))) || + NULL != (ds = (data_string *)array_get_element_klen(p->ssi_vars, var_val, strlen(var_val)))) { chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(ds->value)); } else { chunkqueue_append_mem(con->write_queue, CONST_STR_LEN("(none)")); diff --git a/src/mod_ssi_expr.c b/src/mod_ssi_expr.c index c4376c7a..5cc99469 100644 --- a/src/mod_ssi_expr.c +++ b/src/mod_ssi_expr.c @@ -218,9 +218,9 @@ static int ssi_expr_tokenizer(server *srv, connection *con, handler_ctx *p, tid = TK_VALUE; - if (NULL != (ds = (data_string *)array_get_element(p->ssi_cgi_env, token->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(p->ssi_cgi_env, CONST_BUF_LEN(token)))) { buffer_copy_buffer(token, ds->value); - } else if (NULL != (ds = (data_string *)array_get_element(p->ssi_vars, token->ptr))) { + } else if (NULL != (ds = (data_string *)array_get_element_klen(p->ssi_vars, CONST_BUF_LEN(token)))) { buffer_copy_buffer(token, ds->value); } else { buffer_copy_string_len(token, CONST_STR_LEN("")); diff --git a/src/request.c b/src/request.c index 94fe5580..743589f6 100644 --- a/src/request.c +++ b/src/request.c @@ -860,7 +860,6 @@ int http_request_parse(server *srv, connection *con) { con->parse_request->ptr[i+1] = '\0'; if (in_folding) { - buffer *key_b; /** * we use a evil hack to handle the line-folding * @@ -888,14 +887,9 @@ int http_request_parse(server *srv, connection *con) { return 0; } - key_b = buffer_init(); - buffer_copy_string_len(key_b, key, key_len); - - if (NULL != (ds = (data_string *)array_get_element(con->request.headers, key_b->ptr))) { + if (NULL != (ds = (data_string *)array_get_element_klen(con->request.headers, key, key_len))) { buffer_append_string(ds->value, value); } - - buffer_free(key_b); } else { int s_len; key = con->parse_request->ptr + first; diff --git a/src/server.c b/src/server.c index fb5412e8..acb7c7af 100644 --- a/src/server.c +++ b/src/server.c @@ -1303,7 +1303,7 @@ static int server_main (server * const srv, int argc, char **argv) { continue; } - if (NULL == array_get_element(srv->config_touched, du->key->ptr)) { + if (NULL == array_get_element_klen(srv->config_touched, CONST_BUF_LEN(du->key))) { log_error_write(srv, __FILE__, __LINE__, "sbs", "WARNING: unknown config-key:", du->key, diff --git a/src/stat_cache.c b/src/stat_cache.c index 732e3cf3..882ba6d4 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -292,19 +292,19 @@ const buffer * stat_cache_mimetype_by_ext(const connection *con, const char *nam s = name; } /* search for basename, then longest .ext2.ext1, then .ext1, then "" */ - ds = (data_string *)array_get_element(con->conf.mimetypes, s); + ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s); if (NULL != ds) return ds->value; while (++s < end) { while (*s != '.' && ++s != end) ; if (s == end) break; /* search ".ext" then "ext" */ - ds = (data_string *)array_get_element(con->conf.mimetypes, s); + ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s); if (NULL != ds) return ds->value; /* repeat search without leading '.' to handle situation where * admin configured mimetype.assign keys without leading '.' */ if (++s < end) { if (*s == '.') { --s; continue; } - ds = (data_string *)array_get_element(con->conf.mimetypes, s); + ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s); if (NULL != ds) return ds->value; } } diff --git a/src/status_counter.c b/src/status_counter.c index 0dc267c9..c25cf931 100644 --- a/src/status_counter.c +++ b/src/status_counter.c @@ -21,7 +21,7 @@ data_integer *status_counter_get_counter(server *srv, const char *s, size_t len) { data_integer *di; - if (NULL == (di = (data_integer *)array_get_element(srv->status, s))) { + if (NULL == (di = (data_integer *)array_get_element_klen(srv->status, s, len))) { /* not found, create it */ if (NULL == (di = (data_integer *)array_get_unused_element(srv->status, TYPE_INTEGER))) { |