Commit aaa772c for zlib
commit aaa772ce5c6d0023204c6ee45c59cf70c8372c51
Author: Mark Adler <git@madler.net>
Date: Sun Nov 1 20:34:46 2026 -0800
Honor the promise to detect a bad deflateSetDictionary() call.
There were conditions in which a deflateSetDictionary() call is
made at the wrong time, but Z_OK is returned. Continuing resulted
in an invalid stream. This would be a misuse of the call, but
zlib.h promised to detect it. Now it does.
diff --git a/deflate.c b/deflate.c
index cdb087d..cf20b29 100644
--- a/deflate.c
+++ b/deflate.c
@@ -567,7 +567,8 @@ int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
return Z_STREAM_ERROR;
s = strm->state;
wrap = s->wrap;
- if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
+ if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead ||
+ (wrap == 0 && (long)s->strstart != s->block_start))
return Z_STREAM_ERROR;
/* when using zlib wrappers, compute Adler-32 for provided dictionary */