Fix undefined behavior in STREAM buffer bounds checking by avoiding out-of-bounds pointer arithmetic

This commit is contained in:
Andrea Mazzoleni 2026-08-17 10:12:03 +02:00
parent 3185e1bf34
commit 608393867a
2 changed files with 4 additions and 3 deletions

View file

@ -277,7 +277,7 @@ int sdeplete(STREAM* s, unsigned char* last)
while (1) {
/* increase the position up to 4 bytes before the end */
if (s->pos + 4 <= s->end)
if (s->end - s->pos >= 4)
s->pos = s->end - 4;
/* insert the last 4 bytes */