]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[script] Avoid trying to read final character of a zero-length string
authorMichael Brown <mcb30@ipxe.org>
Mon, 15 Jul 2013 16:06:41 +0000 (18:06 +0200)
committerMichael Brown <mcb30@ipxe.org>
Mon, 15 Jul 2013 16:06:41 +0000 (18:06 +0200)
Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/image/script.c

index 8ef058545e8b49ccf74266ed289afe2e2db94d73..ceccd90183b7532dfaa1f779c8a742199a022780 100644 (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;