File size: 864 Bytes
4eaabb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | diff --git a/src/decode.c b/src/decode.c
index fd8575ad..1bb48962 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -1284,6 +1284,14 @@ decompress_R2004_section (Bit_Chain *restrict src, Bit_Chain *restrict dec)
opcode1 = 0x11;
LOG_INSANE (">O %x!\n", opcode1);
}
+ if (end > dec->size || (long)pos < comp_offset
+ || (size_t)(pos - comp_offset) >= dec->size
+ || (size_t)comp_offset > dec->size)
+ {
+ LOG_ERROR ("Invalid decompression bytes %d, offset %d", comp_bytes,
+ comp_offset);
+ return DWG_ERR_VALUEOUTOFBOUNDS;
+ }
// GH #1204: memmove is wrong here: when comp_offset < comp_bytes the
// source and destination overlap and newly-written bytes must be read
// back (LZ77 run-length extension). memmove copies from original bytes. |