瀏覽代碼

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 年之前
父節點
當前提交
98240d99f0
共有 1 個檔案被更改,包括 4 行新增0 行删除
  1. 4
    0
      src/core/getopt.c

+ 4
- 0
src/core/getopt.c 查看文件

@@ -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…
取消
儲存