From e52c24492af3465657fef882e15da9bc80e3512a Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 15 Jul 2013 18:06:41 +0200 Subject: [script] Avoid trying to read final character of a zero-length string Detected using Valgrind. Signed-off-by: Michael Brown --- src/image/script.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/image') diff --git a/src/image/script.c b/src/image/script.c index 8ef05854..ceccd901 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; -- cgit v1.2.3-55-g7522