summaryrefslogtreecommitdiff
path: root/src/bin/common
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-09-03 00:30:36 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-09-03 00:30:36 +0200
commit3a382d312306f45853b3ad78b770754d4bc7e440 (patch)
treebd64229a27a234ff28d692893d836bf771af53be /src/bin/common
parente5ab1682a1bf52c203b16720011d869901929ac9 (diff)
opj_getopt.c: avoid crash on invalid input (#301)
Diffstat (limited to 'src/bin/common')
-rw-r--r--src/bin/common/opj_getopt.c5
1 files changed, 4 insertions, 1 deletions
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 {