ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 167bd93fdb89177f7d9625aeeeba896fe9ed6ffc
parent ebeac51792eecc8b85fd73282a698a66abc67fe0
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Thu, 10 Dec 2015 18:54:19 +0100

Using 'strtonum' to parse and validate columns parameter value

Diffstat:
Msrc/main.c | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -241,13 +241,18 @@ int main(int argc, char *argv[]) } // default to 160 if columns option is not specified - if (!columns) { - columns = "160"; - } - - // convert numeric command line flags to integer values - int32_t int_columns = atoi(columns); + if (columns) { + // convert numeric command line flags to integer values + int_columns = strtonum(columns, 1, 8192, &errstr); + if (errstr) { + printf("\nInvalid value for columns.\n\n"); + return EXIT_FAILURE; + } + } else { + int_columns = 160; + } + // default to 80x25 font if font option is not specified if (!font) { font = "80x25";