# HG changeset patch # User Matti Hamalainen # Date 1526069498 -10800 # Node ID 19b5013ff190c5852f8807545b67afbf3ff715a6 # Parent 24b8b452925ea4bea68b83f3a9a57400808316c5 Fix c64 bitmap encoding / decoding bounds checks. diff -r 24b8b452925e -r 19b5013ff190 tools/lib64gfx.c --- 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,