david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

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

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-07-15 18:06:41 +02:00
parent 30de9e8300
commit e52c24492a
1 changed files with 2 additions and 2 deletions

View File

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