]> git.kaiwu.me - nginx.git/commit
HTTP: uniform checks in ngx_http_alloc_large_header_buffer().
authorVladimir Khomutov <vl@wbsrv.ru>
Wed, 29 Nov 2023 08:13:05 +0000 (11:13 +0300)
committerVladimir Khomutov <vl@wbsrv.ru>
Wed, 29 Nov 2023 08:13:05 +0000 (11:13 +0300)
commitd8fa024ef1527a9aefbb52bedd70fa4449203488
treecd869e8ed0a81fcde75383c274c40a89dc3ebf7f
parent0db94ba96a00ebfc4a3c55af8eaaf20f971a7c4c
HTTP: uniform checks in ngx_http_alloc_large_header_buffer().

If URI is not fully parsed yet, some pointers are not set.  As a result,
the calculation of "new + (ptr - old)" expression is flawed.

According to C11, 6.5.6 Additive operators, p.9:

: When two pointers are subtracted, both shall point to elements
: of the same array object, or one past the last element of the
: array object

Since "ptr" is not set, subtraction leads to undefined behaviour, because
"ptr" and "old" are not in the same buffer (i.e. array objects).

Prodded by GCC undefined behaviour sanitizer.
src/http/ngx_http_request.c