header value null termination?

Steven Hartland steven.hartland at multiplay.co.uk
Thu Aug 21 23:30:22 UTC 2014

I'm creating a module in which I needed to set some
of the standard headers e.g. Content-Range and Range.

Looking through the core source code the standard way
to do this seems to be something like this:-

r->headers_in.range->value.len =
        "bytes %O-%O/%O",
        range->start, range->end - 1,
        - r->headers_in.range->value.data;

This appears to write a string to value.data which
is not \0 terminated hence when interacting with
functions such as ngx_http_range_parse unpredictable
behaviour follows as it expects the range header to
be null terminated.

So the question is:-

Should header values be null terminated or should
functions such as ngx_http_range_parse be updated
to deal with non-null terminated strings?


More information about the nginx-devel mailing list