Mercurial > hg > dmlib
diff tools/lib64gfx.c @ 921:2454ddb7363f
Add constant for max number of enc/dec ops in C64 image format struct
and check the specified amount against that.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Feb 2015 14:19:46 +0200 |
parents | 9be156fa4b9d |
children | 0f477446448d |
line wrap: on
line diff
--- a/tools/lib64gfx.c Wed Feb 25 14:09:18 2015 +0200 +++ b/tools/lib64gfx.c Wed Feb 25 14:19:46 2015 +0200 @@ -610,6 +610,12 @@ if (buf == NULL || img == NULL || fmt == NULL) return DMERR_NULLPTR; + if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS) + { + dmError("Invalid number of enc/dec ops in format. Internal error.\n"); + return DMERR_INTERNAL; + } + // Clear the image structure memset(img, 0, sizeof(*img)); img->type = fmt->type; @@ -738,6 +744,12 @@ if (pbuf == NULL || plen == NULL || img == NULL || fmt == NULL) return DMERR_NULLPTR; + if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS) + { + dmError("Invalid number of enc/dec ops in format. Internal error.\n"); + return DMERR_INTERNAL; + } + // Allocate the output buffer *plen = 0; if (fmt->size > 0)