33 lines
1.1 KiB
Diff
33 lines
1.1 KiB
Diff
From 723e928b84b0adac84cc11ec5c075a45e1a79903 Mon Sep 17 00:00:00 2001
|
|
From: Mark Adler <zlib@madler.net>
|
|
Date: Thu, 12 Oct 2017 19:44:01 -0700
|
|
Subject: [PATCH] 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.
|
|
|
|
Reference:https://github.com/madler/zlib/commit/723e928b84b0adac84cc11ec5c075a45e1a79903
|
|
Conflict:NA
|
|
---
|
|
trees.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/trees.c b/trees.c
|
|
index 50cf4b4..1321548 100644
|
|
--- a/trees.c
|
|
+++ b/trees.c
|
|
@@ -870,7 +870,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;
|
|
--
|
|
2.23.0
|
|
|