Sfoglia il codice sorgente

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 18 anni fa
parent
commit
98240d99f0
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4
    0
      src/core/getopt.c

+ 4
- 0
src/core/getopt.c Vedi 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…
Annulla
Salva