summaryrefslogtreecommitdiffstats
path: root/external/libjpeg-turbo/ubsan.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /external/libjpeg-turbo/ubsan.patch
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--external/libjpeg-turbo/ubsan.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/external/libjpeg-turbo/ubsan.patch b/external/libjpeg-turbo/ubsan.patch
new file mode 100644
index 000000000..33d3c15a8
--- /dev/null
+++ b/external/libjpeg-turbo/ubsan.patch
@@ -0,0 +1,39 @@
+--- 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)