소스 검색

tools: sunxi: avoid read after end of string

The evaluation of option -c is incorrect:

According to the C99 standard endptr in the first strtol is always
set as &endptr is not NULL.
So the first part of the or condition is always true.
If all digits in optarg are valid endptr will point to the closing \0
and the second strtol will read beyond the end of the string optarg
points to.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
xypron.glpk@gmx.de 7 년 전
부모
커밋
f59a3b21f6
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      tools/sunxi-spl-image-builder.c

+ 1 - 1
tools/sunxi-spl-image-builder.c

@@ -433,7 +433,7 @@ int main(int argc, char **argv)
 			break;
 		case 'c':
 			info.ecc_strength = strtol(optarg, &endptr, 0);
-			if (endptr || *endptr == '/')
+			if (*endptr == '/')
 				info.ecc_step_size = strtol(endptr + 1, NULL, 0);
 			break;
 		case 'p':