diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-12 18:08:03 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-12 19:31:44 +0300 |
commit | 6c2f3cf24f4a03b1eb3689d7913c11c7671c948f (patch) | |
tree | 6ce889376220bcb1921628d9bd34ffcdf3b2ee7d | |
parent | 4017f5a3ed9043e1c9329a3cc91f47be3fee710e (diff) | |
download | libmicrohttpd-6c2f3cf24f4a03b1eb3689d7913c11c7671c948f.tar.gz libmicrohttpd-6c2f3cf24f4a03b1eb3689d7913c11c7671c948f.zip |
postprocessor: fixed undefined behavior error
memcpy() must be called with valid pointers even if size is zero.
Sanitizer doesn't like 'zero pointer with zero offset' as well.
-rw-r--r-- | src/microhttpd/postprocessor.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c index 74f50af5..abe7b437 100644 --- a/src/microhttpd/postprocessor.c +++ b/src/microhttpd/postprocessor.c | |||
@@ -385,11 +385,14 @@ process_value (struct MHD_PostProcessor *pp, | |||
385 | if (delta > XBUF_SIZE - xoff) | 385 | if (delta > XBUF_SIZE - xoff) |
386 | delta = XBUF_SIZE - xoff; | 386 | delta = XBUF_SIZE - xoff; |
387 | /* move (additional) input into processing buffer */ | 387 | /* move (additional) input into processing buffer */ |
388 | memcpy (&xbuf[xoff], | 388 | if (0 != delta) |
389 | value_start, | 389 | { |
390 | delta); | 390 | memcpy (&xbuf[xoff], |
391 | xoff += delta; | 391 | value_start, |
392 | value_start += delta; | 392 | delta); |
393 | xoff += delta; | ||
394 | value_start += delta; | ||
395 | } | ||
393 | /* find if escape sequence is at the end of the processing buffer; | 396 | /* find if escape sequence is at the end of the processing buffer; |
394 | if so, exclude those from processing (reduce delta to point at | 397 | if so, exclude those from processing (reduce delta to point at |
395 | end of processed region) */ | 398 | end of processed region) */ |