浏览代码

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
 	enum getopt_argument_requirement has_arg;
227
 	enum getopt_argument_requirement has_arg;
228
 	int option;
228
 	int option;
229
 
229
 
230
+	/* Check for end of argv array */
231
+	if ( optind >= argc )
232
+		return -1;
233
+
230
 	/* Check for end of options */
234
 	/* Check for end of options */
231
 	if ( *(opttext++) != '-' )
235
 	if ( *(opttext++) != '-' )
232
 		return -1;
236
 		return -1;

正在加载...
取消
保存