changeset 1519:19b5013ff190

Fix c64 bitmap encoding / decoding bounds checks.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 23:11:38 +0300
parents 24b8b452925e
children 2801c76088b5
files tools/lib64gfx.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Fri May 11 23:11:16 2018 +0300
+++ b/tools/lib64gfx.c	Fri May 11 23:11:38 2018 +0300
@@ -506,7 +506,7 @@
             break;
 
         case DT_COLOR_REG:
-            *size = 0;
+            *size = 1;
             break;
 
         default:
@@ -558,7 +558,7 @@
         }
 
         // Do we need to reallocate some more space?
-        if (op->offs + size > len)
+        if (op->offs + size > len + 1)
         {
             return dmError(DMERR_INVALID_DATA,
                 "Decode out of bounds, op #%d type=%d, offs=%d ($%04x), "
@@ -717,7 +717,7 @@
         }
 
         // Do we need to reallocate some more space?
-        chksize = op->offs + size + boffs;
+        chksize = op->offs + size + boffs - 1;
         if (!dmGrowBufCheckGrow(buf, chksize))
         {
             res = dmError(DMERR_MALLOC,