summaryrefslogtreecommitdiffstats
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown2013-07-15 18:06:41 +0200
committerMichael Brown2013-07-15 18:06:41 +0200
commite52c24492af3465657fef882e15da9bc80e3512a (patch)
treef9c473c658ffa95bd8becc19096543c4c935ea20 /src/image
parent[nfs] Add support for NFS protocol (diff)
downloadipxe-e52c24492af3465657fef882e15da9bc80e3512a.tar.gz
ipxe-e52c24492af3465657fef882e15da9bc80e3512a.tar.xz
ipxe-e52c24492af3465657fef882e15da9bc80e3512a.zip
[script] Avoid trying to read final character of a zero-length string
Detected using Valgrind. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/script.c4
1 files changed, 2 insertions, 2 deletions
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;