Skip to content

Commit

Permalink
v1.0.5: fix buffer overrun when reading bad WebPs
Browse files Browse the repository at this point in the history
  • Loading branch information
landfillbaby committed Jul 23, 2022
1 parent 6e0553b commit 8f21ad7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion png2webp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// anti-copyright Lucy Phipps 2022
// vi: sw=2 tw=80
#define VERSION "v1.0.4"
#define VERSION "v1.0.5"
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
Expand Down Expand Up @@ -319,6 +319,14 @@ static bool w2p(char *ip, char *op) {
}
size_t l = ((uint32_t)(i[4] | (i[5] << 8) | (i[6] << 16) | (i[7] << 24))) + 8;
// ^ RIFF header size
if(l <= 12
#ifdef SSIZE_MAX
|| l - 12 > SSIZE_MAX
#endif
) {
PF("ERROR reading %s: %s", IP, k[2]);
goto w2p_close;
}
x = malloc(l);
if(!x) {
PF("ERROR reading %s: %s", IP, *k);
Expand Down

0 comments on commit 8f21ad7

Please sign in to comment.