summaryrefslogtreecommitdiff
path: root/ff2png.c
diff options
context:
space:
mode:
authorFRIGN <dev@frign.de>2016-03-18 19:49:11 +0100
committerFRIGN <dev@frign.de>2016-03-18 19:49:11 +0100
commite637aae67ededf6a4a0b4d490d02f3294f297b71 (patch)
tree8f09a69a6f68aed99205239f6eef1c11d3943b47 /ff2png.c
parent49cef794d9cef3c1ab8478963a7f778c8c28eb70 (diff)
Prevent overflow in rowlen and improve inaccuracies in style
Diffstat (limited to 'ff2png.c')
-rw-r--r--ff2png.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ff2png.c b/ff2png.c
index bf210fb..4304bbb 100644
--- a/ff2png.c
+++ b/ff2png.c
@@ -61,7 +61,11 @@ main(int argc, char *argv[])
png_write_info(pngs, pngi);
/* write rows */
- rowlen = (sizeof("RGBA") - 1) * width;
+ if (width > SIZE_MAX / ((sizeof("RGBA") - 1) * sizeof(uint16_t))) {
+ fprintf(stderr, "%s: row length integer overflow\n", argv0);
+ return 1;
+ }
+ rowlen = width * (sizeof("RGBA") - 1);
if (!(row = malloc(rowlen * sizeof(uint16_t)))) {
fprintf(stderr, "%s: malloc: out of memory\n", argv0);
return 1;