From: Michael Brown Date: Sun, 14 Jan 2007 02:01:26 +0000 (+0000) Subject: Do not go past the end of the argv[] array. X-Git-Tag: v0.9.3~606 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98240d99f01edb9f211af4dfb5da53ea0d3b81e5;p=thirdparty%2Fipxe.git Do not go past the end of the argv[] array. This bug found by setting read and write watchpoints at NULL in bochs. --- diff --git a/src/core/getopt.c b/src/core/getopt.c index 4e839cab2..547aa6940 100644 --- a/src/core/getopt.c +++ b/src/core/getopt.c @@ -227,6 +227,10 @@ int getopt_long ( int argc, char * const argv[], const char *optstring, enum getopt_argument_requirement has_arg; int option; + /* Check for end of argv array */ + if ( optind >= argc ) + return -1; + /* Check for end of options */ if ( *(opttext++) != '-' ) return -1;