]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[script] Accept labels on lines terminated with CRLF
authorMichael Brown <mcb30@ipxe.org>
Mon, 8 Aug 2011 15:35:30 +0000 (16:35 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 8 Aug 2011 15:35:30 +0000 (16:35 +0100)
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>
src/image/script.c

index 161ac682e7cc650cabd80261910d2ebbe6ff52b9..fb89e422062aeceb4d42ab357f2a0298f1e0bcd7 100644 (file)
@@ -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;
 }