Skip to content

Instantly share code, notes, and snippets.

@Freaky
Last active October 30, 2023 23:47
Show Gist options
  • Save Freaky/0effd5f4bd3895f256329289bc45897e to your computer and use it in GitHub Desktop.
Save Freaky/0effd5f4bd3895f256329289bc45897e to your computer and use it in GitHub Desktop.
Workaround for OptiPNG 0.7.7's CVE-2023-43907
--- src/gifread/gifread.c.orig 2023-10-30 19:44:00.082877489 +0000
+++ src/gifread/gifread.c 2023-10-30 22:42:08.789142913 +0000
@@ -363,6 +363,11 @@
lastbit = (2 + count) * 8;
}
+ if (code_size && (size_t)(curbit + code_size - 1) / 8 >= sizeof(buffer)) {
+ GIFError("Malformed GIF (CVE-2023-43907)");
+ return -1;
+ }
+
ret = 0;
for (i = curbit, j = 0; j < code_size; ++i, ++j)
ret |= ((buffer[i / 8] & (1 << (i % 8))) != 0) << j;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment