summaryrefslogtreecommitdiffstats
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown2011-08-08 17:35:30 +0200
committerMichael Brown2011-08-08 17:35:30 +0200
commit174df77359f22f3be2169e9bb04e8018015b5e94 (patch)
treeb5ef7a672c4d066ed5057620c875b40634db4ad5 /src/image
parent[lkrnprefix] Fix lost command line passed by grub (diff)
downloadipxe-174df77359f22f3be2169e9bb04e8018015b5e94.tar.gz
ipxe-174df77359f22f3be2169e9bb04e8018015b5e94.tar.xz
ipxe-174df77359f22f3be2169e9bb04e8018015b5e94.zip
[script] Accept labels on lines terminated with CRLF
CRLF line terminators are allowed in scripts; the carriage return is simply interpreted as trailing whitespace and so is ignored. This fails on lines containing script labels, since the label-finding code checks for a line containing only the ":" marker and the label itself (without any trailing whitespace). Fix by allowing a label to be terminated by either a NUL or a whitespace character. Reported-by: Bovey Christian <Christian.Bovey@chuv.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/script.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/image/script.c b/src/image/script.c
index 161ac682..fb89e422 100644
--- a/src/image/script.c
+++ b/src/image/script.c
@@ -221,11 +221,17 @@ static const char *goto_label;
* @ret rc Return status code
*/
static int goto_find_label ( const char *line ) {
+ size_t len = strlen ( goto_label );
if ( line[0] != ':' )
return -ENOENT;
- if ( strcmp ( goto_label, &line[1] ) != 0 )
+
+ if ( strncmp ( goto_label, &line[1], len ) != 0 )
+ return -ENOENT;
+
+ if ( line[ 1 + len ] && ! isspace ( line[ 1 + len ] ) )
return -ENOENT;
+
return 0;
}