Browse Source

Do not go past the end of the argv[] array.

This bug found by setting read and write watchpoints at NULL in bochs.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
98240d99f0
1 changed files with 4 additions and 0 deletions
  1. 4
    0
      src/core/getopt.c

+ 4
- 0
src/core/getopt.c View File

@@ -227,6 +227,10 @@ int getopt_long ( int argc, char * const argv[], const char *optstring,
227 227
 	enum getopt_argument_requirement has_arg;
228 228
 	int option;
229 229
 
230
+	/* Check for end of argv array */
231
+	if ( optind >= argc )
232
+		return -1;
233
+
230 234
 	/* Check for end of options */
231 235
 	if ( *(opttext++) != '-' )
232 236
 		return -1;

Loading…
Cancel
Save