v2-pglz_decompress_check_for_corrupted.patch
text/x-patch
Filename: v2-pglz_decompress_check_for_corrupted.patch
Type: text/x-patch
Part: 0
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/common/pg_lzcompress.c | 3 | 1 |
--- a/src/common/pg_lzcompress.c 2023-10-18 12:34:30.616000000 +0000 +++ b/src/common/pg_lzcompress.c 2023-10-18 16:42:17.856000000 +0000 @@ -738,8 +738,10 @@ * source, or if we obtained off = 0, we have problems. (We * must check this, else we risk an infinite loop below in the * face of corrupt data.) + * Also check if we fell before the beginning of the + * destination. */ - if (unlikely(sp > srcend || off == 0)) + if (unlikely(sp > srcend || off == 0 || (dp - off) < dest)) return -1; /*