libansilove

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

commit acd4cd297341b545a5cc74593f3700f4ba016bc7
parent a315e1d21f5c6a193e1d36aebd6eca671b574499
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 21 Oct 2020 23:25:20 +0200

Add additional file format integrity check in the XBin loader.

Diffstat:
Msrc/loaders/xbin.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -154,9 +154,15 @@ ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) while (counter--) { /* none */ if (ctype == 0) { - character = ctx->buffer[offset]; - attribute = ctx->buffer[offset + 1]; - offset += 2; + if (offset + 1 < ctx->length) { + character = ctx->buffer[offset]; + attribute = ctx->buffer[offset + 1]; + offset += 2; + } else { + ctx->error = ANSILOVE_FORMAT_ERROR; + free(font_data_xbin); + return -1; + } } /* char */ else if (ctype == 0x40) {