changeset 2533:78ece6187a7c

Make sure we won't access DMC64Image::extraData[] indices out of bounds when dumping memory blocks.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 12 Jul 2020 01:01:37 +0300
parents f3be70c19ce9
children d6b9410f1b1b 5f76cf36e5c5
files tools/gfxconv.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/gfxconv.c	Sun Jul 12 01:00:59 2020 +0300
+++ b/tools/gfxconv.c	Sun Jul 12 01:01:37 2020 +0300
@@ -1765,8 +1765,10 @@
         res = dmDumpC64Block(fprefix, "bitmap", &img->bitmap[i], i);
         res = dmDumpC64Block(fprefix, "color", &img->color[i], i);
         res = dmDumpC64Block(fprefix, "screen", &img->screen[i], i);
-        res = dmDumpC64Block(fprefix, "extradata", &img->extraData[i], i);
         res = dmDumpC64Block(fprefix, "chardata", &img->charData[i], i);
+
+        if ((size_t) i < sizeof(img->extraData) / sizeof(img->extraData[0]))
+            res = dmDumpC64Block(fprefix, "extradata", &img->extraData[i], i);
     }
 
     return res;