libansilove

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

commit a315e1d21f5c6a193e1d36aebd6eca671b574499
parent a29249a4ffe3a1b2a801a1d4ceeea6dc93e6e598
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 21 Oct 2020 20:57:01 +0200

Add range integrity checks for bits value in relevant loaders.

Diffstat:
Msrc/loaders/ansi.c | 5+++++
Msrc/loaders/binary.c | 5+++++
Msrc/loaders/pcboard.c | 5+++++
Msrc/loaders/tundra.c | 5+++++
4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -100,6 +100,11 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } + if (options->bits != 8 && options->bits !=9) { + ctx->error = ANSILOVE_RANGE_ERROR; + return -1; + } + /* Default to 80 columns if columns option wasn't set */ options->columns = options->columns ? options->columns : 80; diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -49,6 +49,11 @@ ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } + if (options->bits != 8 && options->bits !=9) { + ctx->error = ANSILOVE_RANGE_ERROR; + return -1; + } + /* font selection */ memset(&fontData, 0, sizeof(struct fontStruct)); select_font(&fontData, options->font); diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -66,6 +66,11 @@ ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options) return -1; } + if (options->bits != 8 && options->bits !=9) { + ctx->error = ANSILOVE_RANGE_ERROR; + return -1; + } + options->columns = options->columns ? options->columns : 80; uint16_t columns = options->columns; diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -52,6 +52,11 @@ ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) if (ctx->length < TUNDRA_HEADER_LENGTH) goto error; + if (options->bits != 8 && options->bits !=9) { + ctx->error = ANSILOVE_RANGE_ERROR; + return -1; + } + options->columns = options->columns ? options->columns : 80; int16_t columns = options->columns;