summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2025-11-14 18:14:18 +0400
committerSergey Kandaurov <s.kandaurov@f5.com>2025-11-19 18:52:54 +0400
commit6ed1188411882086e3518eda779ab782d8ab4d3f (patch)
tree8d4e3f7f062940e9ef7ade2a1255febc75f71441 /src/http
parent9d04b6630aa77de45d8946f84edfc6c174f15c70 (diff)
downloadnginx-6ed1188411882086e3518eda779ab782d8ab4d3f.tar.gz
nginx-6ed1188411882086e3518eda779ab782d8ab4d3f.tar.bz2
HTTP/2: extended guard for NULL buffer and zero length.
In addition to moving memcpy() under the length condition in 15bf6d8cc, which addressed a reported UB due to string function conventions, this is repeated for advancing an input buffer, to make the resulting code more clean and readable. Additionally, although considered harmless for both string functions and additive operators, as previously discussed in GitHub PR 866, this fixes the main source of annoying sanitizer reports in the module. Prodded by UndefinedBehaviorSanitizer (pointer-overflow).
Diffstat (limited to 'src/http')
-rw-r--r--src/http/v2/ngx_http_v2.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
index fe9ee5a88..4bfee589a 100644
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -4113,15 +4113,14 @@ ngx_http_v2_process_request_body(ngx_http_request_t *r, u_char *pos,
n = size;
}
- if (n > 0) {
- rb->buf->last = ngx_cpymem(rb->buf->last, pos, n);
- }
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, fc->log, 0,
"http2 request body recv %uz", n);
- pos += n;
- size -= n;
+ if (n > 0) {
+ rb->buf->last = ngx_cpymem(rb->buf->last, pos, n);
+ pos += n;
+ size -= n;
+ }
if (size == 0 && last) {
rb->rest = 0;