diff options
| author | Mark Adler <zlib@madler.net> | 2017-10-12 19:44:01 -0700 |
|---|---|---|
| committer | Mark Adler <zlib@madler.net> | 2017-10-12 19:44:01 -0700 |
| commit | 723e928b84b0adac84cc11ec5c075a45e1a79903 (patch) | |
| tree | 5090ac2d115e17a71528780ad8efe70b74f907fa | |
| parent | b25d5fcdcf4723ca3da8bc69ecc6c52010778f7c (diff) | |
| download | zlib-723e928b84b0adac84cc11ec5c075a45e1a79903.tar.gz zlib-723e928b84b0adac84cc11ec5c075a45e1a79903.tar.bz2 zlib-723e928b84b0adac84cc11ec5c075a45e1a79903.zip | |
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.
| -rw-r--r-- | trees.c | 3 |
1 files changed, 2 insertions, 1 deletions
| @@ -870,7 +870,8 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |||
| 870 | bi_windup(s); /* align on byte boundary */ | 870 | bi_windup(s); /* align on byte boundary */ |
| 871 | put_short(s, (ush)stored_len); | 871 | put_short(s, (ush)stored_len); |
| 872 | put_short(s, (ush)~stored_len); | 872 | put_short(s, (ush)~stored_len); |
| 873 | zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); | 873 | if (stored_len) |
| 874 | zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); | ||
| 874 | s->pending += stored_len; | 875 | s->pending += stored_len; |
| 875 | #ifdef ZLIB_DEBUG | 876 | #ifdef ZLIB_DEBUG |
| 876 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; | 877 | s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; |
