Skip to content

Commit

Permalink
Merge pull request #48 from anthonyryan1/master
Browse files Browse the repository at this point in the history
ngx_http_variable_unknown_header was causing segfaults
  • Loading branch information
evanmiller committed May 11, 2015
2 parents 9624d21 + 30de339 commit 01ce916
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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

0 comments on commit 01ce916

Please sign in to comment.