office-gobmx/external/libjpeg-turbo/ubsan.patch
Caolán McNamara 35bb14d857 ofz#3782 libjpeg ubsan woes
https://github.com/libjpeg-turbo/libjpeg-turbo/issues/171

Change-Id: Ic6d7e27f88a542d78f3257418099c8fd875b04c9
Reviewed-on: https://gerrit.libreoffice.org/43812
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-10-25 16:00:25 +02:00

39 lines
997 B
Diff

--- jcphuff.c
+++ jcphuff.c
@@ -14,6 +14,7 @@
* suspension.
*/
+#include <stdint.h>
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
@@ -255,7 +256,7 @@
if (c == 0xFF) { /* need to stuff a zero byte? */
emit_byte(entropy, 0);
}
- put_buffer <<= 8;
+ put_buffer = (uint_least32_t) put_buffer << 8;
put_bits -= 8;
}
--- jdarith.c
+++ jdarith.c
@@ -306,7 +306,7 @@
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
- entropy->last_dc_val[ci] += v;
+ entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
}
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
@@ -564,7 +564,7 @@
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
- entropy->last_dc_val[ci] += v;
+ entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
}
if (block)