Skip to content

Commit f1288ad

Browse files
committed
Fix: Heap OOB read in pt_decompress
GHSL-2026-139 Credit: discovered and reported by GHSL team member @JarLob Remediation: require in->size >= 14
1 parent 66c81e4 commit f1288ad

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

C/zstdmt/lizard-mt_decompress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ static void *pt_decompress(void *arg)
328328
if (in->size < 40 && ctx->frames == 1) {
329329
out->size = 1024 * 64;
330330
} else {
331+
if (in->size < 14) {
332+
result = ERROR(data_error);
333+
goto error_lock;
334+
}
331335
/* get frame size for output buffer */
332336
unsigned char *src = (unsigned char *)in->buf + 6;
333337
out->size = (size_t) MEM_readLE64(src);

C/zstdmt/lz4-mt_decompress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ static void *pt_decompress(void *arg)
328328
if (in->size < 40 && ctx->frames == 1) {
329329
out->size = 1024 * 64;
330330
} else {
331+
if (in->size < 14) {
332+
result = ERROR(data_error);
333+
goto error_lock;
334+
}
331335
/* get frame size for output buffer */
332336
unsigned char *src = (unsigned char *)in->buf + 6;
333337
out->size = (size_t) MEM_readLE64(src);

C/zstdmt/lz5-mt_decompress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ static void *pt_decompress(void *arg)
328328
if (in->size < 40 && ctx->frames == 1) {
329329
out->size = 1024 * 64;
330330
} else {
331+
if (in->size < 14) {
332+
result = ERROR(data_error);
333+
goto error_lock;
334+
}
331335
/* get frame size for output buffer */
332336
unsigned char *src = (unsigned char *)in->buf + 6;
333337
out->size = (size_t) MEM_readLE64(src);

0 commit comments

Comments
 (0)