From: Even Rouault Date: Sat, 2 Sep 2017 22:30:36 +0000 (+0200) Subject: opj_getopt.c: avoid crash on invalid input (#301) X-Git-Tag: v2.3.0~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a382d312306f45853b3ad78b770754d4bc7e440;p=openjpeg opj_getopt.c: avoid crash on invalid input (#301) --- diff --git a/src/bin/common/opj_getopt.c b/src/bin/common/opj_getopt.c index 5db94ca0..11ccfc59 100644 --- a/src/bin/common/opj_getopt.c +++ b/src/bin/common/opj_getopt.c @@ -160,12 +160,15 @@ again: } if (argv[opj_optind][0] == '-') { /* long option */ - char* arg = argv[opj_optind] + 1; + char* arg; const opj_option_t* o; o = longopts; len = sizeof(longopts[0]); if (param > 1) { + if (opj_optind + 1 >= argc) { + return -1; + } arg = argv[opj_optind + 1]; opj_optind++; } else {