From: Michael Brown Date: Mon, 15 Jul 2013 16:06:41 +0000 (+0200) Subject: [script] Avoid trying to read final character of a zero-length string X-Git-Tag: v1.20.1~1466 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e52c24492af3465657fef882e15da9bc80e3512a;p=thirdparty%2Fipxe.git [script] Avoid trying to read final character of a zero-length string Detected using Valgrind. Signed-off-by: Michael Brown --- diff --git a/src/image/script.c b/src/image/script.c index 8ef058545..ceccd9018 100644 --- a/src/image/script.c +++ b/src/image/script.c @@ -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;