[master] 2d6dc0c From upstream:

Federico G. Schwindt fgsch at lodoss.net
Sun Oct 22 07:30:12 UTC 2017


commit 2d6dc0c5c67e23af8fe9a30689871dabbb6f57ef
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Sat Oct 21 20:12:08 2017 -0700

    From upstream:
    
    Avoid an undefined behavior of memcpy() in _tr_stored_block().
    
    Allegedly the behavior of memcpy() is undefined if the source
    pointer is NULL, even if the number of bytes to copy is zero.

diff --git a/lib/libvgz/trees.c b/lib/libvgz/trees.c
index 10464f6..92a50f2 100644
--- a/lib/libvgz/trees.c
+++ b/lib/libvgz/trees.c
@@ -874,7 +874,8 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
     bi_windup(s);        /* align on byte boundary */
     put_short(s, (ush)stored_len);
     put_short(s, (ush)~stored_len);
-    zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
+    if (stored_len)
+        zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
     s->pending += stored_len;
 #ifdef ZLIB_DEBUG
     s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;


More information about the varnish-commit mailing list