ソースを参照

[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 12年前
コミット
e52c24492a
1個のファイルの変更2行の追加2行の削除
  1. 2
    2
      src/image/script.c

+ 2
- 2
src/image/script.c ファイルの表示

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

読み込み中…
キャンセル
保存