mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
*) fix segfaults in types hash
*) fix inheritance: default hash instead of inherited one
This commit is contained in:
parent
d1853490da
commit
c71e3d8f81
@ -1484,6 +1484,14 @@ ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
ngx_http_charset_recode_t *recode;
|
||||
ngx_http_charset_main_conf_t *mcf;
|
||||
|
||||
if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
|
||||
prev->types_keys, &prev->types,
|
||||
ngx_http_charset_default_types)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_conf_merge_value(conf->override_charset, prev->override_charset, 0);
|
||||
ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET);
|
||||
|
||||
@ -1523,14 +1531,6 @@ ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||
recode->src = conf->source_charset;
|
||||
recode->dst = conf->charset;
|
||||
|
||||
if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
|
||||
prev->types_keys, &prev->types,
|
||||
ngx_http_charset_default_types)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
@ -1761,43 +1761,60 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
char *
|
||||
ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, ngx_hash_t *types_hash,
|
||||
ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
|
||||
ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
|
||||
ngx_str_t *default_types)
|
||||
{
|
||||
ngx_hash_init_t hash;
|
||||
|
||||
if (keys == NULL) {
|
||||
if (keys) {
|
||||
|
||||
if (prev_keys) {
|
||||
*types_hash = *prev_types_hash;
|
||||
return NGX_CONF_OK;
|
||||
hash.hash = types_hash;
|
||||
hash.key = NULL;
|
||||
hash.max_size = 2048;
|
||||
hash.bucket_size = 64;
|
||||
hash.name = "test_types_hash";
|
||||
hash.pool = cf->pool;
|
||||
hash.temp_pool = NULL;
|
||||
|
||||
if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_http_set_default_types(cf, &keys, default_types)
|
||||
!= NGX_CONF_OK)
|
||||
{
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
if (prev_types_hash->buckets == NULL) {
|
||||
|
||||
if (prev_keys == NULL) {
|
||||
|
||||
if (ngx_http_set_default_types(cf, &prev_keys, default_types)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
hash.hash = prev_types_hash;
|
||||
hash.key = NULL;
|
||||
hash.max_size = 2048;
|
||||
hash.bucket_size = 64;
|
||||
hash.name = "test_types_hash";
|
||||
hash.pool = cf->pool;
|
||||
hash.temp_pool = NULL;
|
||||
|
||||
if (ngx_hash_init(&hash, prev_keys->elts, prev_keys->nelts) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
hash.hash = types_hash;
|
||||
hash.key = NULL;
|
||||
hash.max_size = 2048;
|
||||
hash.bucket_size = 64;
|
||||
hash.name = "test_types_hash";
|
||||
hash.pool = cf->pool;
|
||||
hash.temp_pool = NULL;
|
||||
|
||||
if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
*types_hash = *prev_types_hash;
|
||||
|
||||
return NGX_CONF_OK;
|
||||
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
ngx_int_t
|
||||
ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
|
||||
ngx_str_t *default_type)
|
||||
{
|
||||
@ -1805,14 +1822,14 @@ ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
|
||||
|
||||
*types = ngx_array_create(cf->temp_pool, 1, sizeof(ngx_hash_key_t));
|
||||
if (*types == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
while (default_type->len) {
|
||||
|
||||
type = ngx_array_push(*types);
|
||||
if (type == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
type->key = *default_type;
|
||||
@ -1823,5 +1840,5 @@ ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
|
||||
default_type++;
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ char *ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
char *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys,
|
||||
ngx_hash_t *types_hash, ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
|
||||
ngx_str_t *default_types);
|
||||
char *ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
|
||||
ngx_int_t ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
|
||||
ngx_str_t *default_type);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user