libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit 02527f85788b3bfd37ed591d82facc549be1935f
parent 718d171fa9410db5569627308165b2aa8e1df4eb
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 24 Oct 2018 15:34:48 +0200

Add format validation checks for ADF and IDF loaders

Diffstat:
Msrc/loaders/artworx.c | 5+++++
Msrc/loaders/icedraw.c | 5+++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -22,6 +22,11 @@ int ansilove_artworx(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } + if (ctx->length < ADF_HEADER_LENGTH) { + ctx->error = ANSILOVE_FORMAT_ERROR; + return -1; + } + // libgd image pointers gdImagePtr canvas; diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -22,6 +22,11 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } + if (ctx->length < IDF_HEADER_LENGTH) { + ctx->error = ANSILOVE_FORMAT_ERROR; + return -1; + } + // extract relevant part of the IDF header, 16-bit endian unsigned short uint32_t x2 = (ctx->buffer[9] << 8) + ctx->buffer[8];