]> git.kaiwu.me - nginx.git/commitdiff
HTTP/2: avoid memcpy() with NULL source and zero length.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 31 Aug 2021 13:44:13 +0000 (16:44 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 31 Aug 2021 13:44:13 +0000 (16:44 +0300)
Prodded by Clang Static Analyzer.

src/http/v2/ngx_http_v2.c

index 5ccb363601a3134fce75c2de55389ee7e8243506..79c4f17c204693f5e61377a382e8ed4a4f98d1cd 100644 (file)
@@ -4241,7 +4241,9 @@ ngx_http_v2_process_request_body(ngx_http_request_t *r, u_char *pos,
                 n = size;
             }
 
-            rb->buf->last = ngx_cpymem(rb->buf->last, pos, n);
+            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);