diff options
author | Michael Brown | 2007-01-14 03:01:26 +0100 |
---|---|---|
committer | Michael Brown | 2007-01-14 03:01:26 +0100 |
commit | 98240d99f01edb9f211af4dfb5da53ea0d3b81e5 (patch) | |
tree | a106a13bb8f86219dccd78c9965ab8605f392250 /src/core/getopt.c | |
parent | Use debug autocolourisation. (diff) | |
download | ipxe-98240d99f01edb9f211af4dfb5da53ea0d3b81e5.tar.gz ipxe-98240d99f01edb9f211af4dfb5da53ea0d3b81e5.tar.xz ipxe-98240d99f01edb9f211af4dfb5da53ea0d3b81e5.zip |
Do not go past the end of the argv[] array.
This bug found by setting read and write watchpoints at NULL in bochs.
Diffstat (limited to 'src/core/getopt.c')
-rw-r--r-- | src/core/getopt.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/getopt.c b/src/core/getopt.c index 4e839cab..547aa694 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; |