소스 검색

[script] Avoid trying to read final character of a zero-length string

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 년 전
부모
커밋
e52c24492a
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2
    2
      src/image/script.c

+ 2
- 2
src/image/script.c 파일 보기

@@ -92,11 +92,11 @@ static int process_script ( struct image *image,
92 92
 		script_offset += ( frag_len + 1 );
93 93
 
94 94
 		/* Strip trailing CR, if present */
95
-		if ( line[ len - 1 ] == '\r' )
95
+		if ( len && ( line[ len - 1 ] == '\r' ) )
96 96
 			len--;
97 97
 
98 98
 		/* Handle backslash continuations */
99
-		if ( line[ len - 1 ] == '\\' ) {
99
+		if ( len && ( line[ len - 1 ] == '\\' ) ) {
100 100
 			len--;
101 101
 			rc = -EINVAL;
102 102
 			continue;

Loading…
취소
저장