ref: 8d7b9198e3830bb1ae37ac3b3f44c60582c86f81
parent: cf4224adb9f1ddd7feccc585e162304829f6bd40
author: Werner Lemberg <[email protected]>
date: Tue Aug 16 04:07:58 EDT 2016
[lzw] Avoid buffer overrun. Reported as https://bugzilla.mozilla.org/show_bug.cgi?id=1273283 * src/lzw/ftzopen.c (ft_lzwstate_refill): Ensure `buf_size' doesn't underflow.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2016-08-16 Werner Lemberg <[email protected]>
+ [lzw] Avoid buffer overrun.
+
+ Reported as
+
+ https://bugzilla.mozilla.org/show_bug.cgi?id=1273283
+
+ * src/lzw/ftzopen.c (ft_lzwstate_refill): Ensure `buf_size' doesn't
+ underflow.
+
+2016-08-16 Werner Lemberg <[email protected]>
+
[truetype] Fix compiler warning.
* src/truetype/ttgload.c (load_truetype_glyph): Add cast.
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -42,7 +42,12 @@
state->buf_total += count;
state->in_eof = FT_BOOL( count < state->num_bits );
state->buf_offset = 0;
- state->buf_size = ( state->buf_size << 3 ) - ( state->num_bits - 1 );
+
+ state->buf_size <<= 3;
+ if ( state->buf_size > state->num_bits )
+ state->buf_size -= state->num_bits - 1;
+ else
+ return -1; /* not enough data */
if ( count == 0 ) /* end of file */
return -1;