libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 6c2f3cf24f4a03b1eb3689d7913c11c7671c948f
parent 4017f5a3ed9043e1c9329a3cc91f47be3fee710e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 12 Sep 2021 18:08:03 +0300

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.

Diffstat:
Msrc/microhttpd/postprocessor.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c @@ -385,11 +385,14 @@ process_value (struct MHD_PostProcessor *pp, if (delta > XBUF_SIZE - xoff) delta = XBUF_SIZE - xoff; /* move (additional) input into processing buffer */ - memcpy (&xbuf[xoff], - value_start, - delta); - xoff += delta; - value_start += delta; + if (0 != delta) + { + memcpy (&xbuf[xoff], + value_start, + delta); + xoff += delta; + value_start += delta; + } /* find if escape sequence is at the end of the processing buffer; if so, exclude those from processing (reduce delta to point at end of processed region) */