Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngx_http_variable_unknown_header was causing segfaults #48

Merged
merged 2 commits into from
May 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions ngx_http_zip_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ ngx_http_zip_add_cache_control(ngx_http_request_t *r)
}

cc->hash = 1;
cc->key.len = sizeof("Cache-Control") - 1;
cc->key.data = (u_char *) "Cache-Control";
ngx_str_set(&cc->key, "Cache-Control");

*ccp = cc;

Expand All @@ -44,8 +43,7 @@ ngx_http_zip_add_cache_control(ngx_http_request_t *r)
cc = ccp[0];
}

cc->value.len = sizeof("max-age=0") - 1;
cc->value.data = (u_char *) "max-age=0";
ngx_str_set(&cc->value, "max-age=0");

return NGX_OK;
}
Expand All @@ -63,8 +61,7 @@ ngx_http_zip_add_content_range_header(ngx_http_request_t *r)
r->headers_out.content_range = content_range;

content_range->hash = 1;
content_range->key.len = sizeof("Content-Range") - 1;
content_range->key.data = (u_char *) "Content-Range";
ngx_str_set(&content_range->key, "Content-Range");

if (r->headers_out.content_length) {
r->headers_out.content_length->hash = 0;
Expand Down Expand Up @@ -201,8 +198,7 @@ ngx_http_zip_strip_range_header(ngx_http_request_t *r)
header = r->headers_in.range;

if (header) {
header->key.data = (u_char *)"X-Range";
header->key.len = sizeof("X-Range") - 1;
ngx_str_set(&header->key, "X-Range");
header->lowcase_key = (u_char *)"x-range";
}

Expand Down
4 changes: 3 additions & 1 deletion ngx_http_zip_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ ngx_http_zip_main_request_header_filter(ngx_http_request_t *r)
if (r->upstream) {
variable_header_status = ngx_http_upstream_header_variable(r, vv,
(uintptr_t)(&ngx_http_zip_header_variable_name));
} else {
} else if (r->headers_out.status == NGX_HTTP_OK) {
variable_header_status = ngx_http_variable_unknown_header(vv,
&ngx_http_zip_header_variable_name,
&r->headers_out.headers.part, sizeof("upstream_http_") - 1);
} else {
vv->not_found = 1;
}

if (variable_header_status != NGX_OK || vv->not_found ||
Expand Down