From 980e039743b8050d7e1a6a86af92fe40a6e30c75 Mon Sep 17 00:00:00 2001 From: gitlost Date: Wed, 5 Aug 2020 15:58:21 +0100 Subject: [PATCH] command line: avoid arg_opts buffer overflow if -d/i used without space before arg --- backend/common.c | 2 +- backend/common.h | 2 +- frontend/main.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/common.c b/backend/common.c index c3b9d0c2..f9a36060 100644 --- a/backend/common.c +++ b/backend/common.c @@ -240,7 +240,7 @@ INTERNAL int is_extendable(const int symbology) { } /* Indicates which symbols can have composite 2D component data */ -INTERNAL int is_composite(int symbology) { +INTERNAL int is_composite(const int symbology) { return symbology >= BARCODE_EANX_CC && symbology <= BARCODE_DBAR_EXPSTK_CC; } diff --git a/backend/common.h b/backend/common.h index b86d2766..c2e348ec 100644 --- a/backend/common.h +++ b/backend/common.h @@ -87,7 +87,7 @@ extern "C" { INTERNAL int is_stackable(const int symbology); INTERNAL int is_extendable(const int symbology); INTERNAL int is_composite(const int symbology); - INTERNAL int istwodigits(const unsigned char source[], int length, const int position); + INTERNAL int istwodigits(const unsigned char source[], const int length, const int position); INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte); INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[], size_t *length, int disallow_4byte); INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_height); diff --git a/frontend/main.c b/frontend/main.c index 48ab3ad2..dcd64a65 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -515,9 +515,9 @@ int main(int argc, char **argv) { char *outfile_extension; int data_arg_num = 0; #ifndef _MSC_VER - arg_opt arg_opts[(argc + 1) / 2]; + arg_opt arg_opts[argc]; #else - arg_opt *arg_opts = (arg_opt *) _alloca(((argc + 1) / 2) * sizeof(arg_opt)); + arg_opt *arg_opts = (arg_opt *) _alloca(argc * sizeof(arg_opt)); #endif my_symbol = ZBarcode_Create();