libansilove

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

commit 3708c6237d40b1ac7fe744ecc33eefdd8021a231
parent 6403aaaa5091a8b664331b2c79eab41f0a470602
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu, 24 Sep 2020 10:07:21 +0200

Add some file format integrity checks in the XBin loader.

Do not plot characters if we don't have 2 bytes of data for a character
cell.

Diffstat:
Msrc/loaders/xbin.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -132,7 +132,7 @@ ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) /* read compressed xbin */ if ((xbin_flags & 4) == 4) { - while (offset < ctx->length && row != xbin_height) { + while (offset + 1 < ctx->length && row != xbin_height) { uint32_t ctype = ctx->buffer[offset] & 0xC0; uint32_t counter = (ctx->buffer[offset] & 0x3F) + 1; @@ -194,7 +194,7 @@ ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) } } else { /* read uncompressed xbin */ - while (offset < ctx->length && row != xbin_height) { + while (offset + 1 < ctx->length && row != xbin_height) { if (column == xbin_width) { column = 0; row++;