Kaynağa Gözat

[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>
tags/v1.20.1
Michael Brown 12 yıl önce
ebeveyn
işleme
174df77359
1 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 7
    1
      src/image/script.c

+ 7
- 1
src/image/script.c Dosyayı Görüntüle

@@ -221,11 +221,17 @@ static const char *goto_label;
221 221
  * @ret rc		Return status code
222 222
  */
223 223
 static int goto_find_label ( const char *line ) {
224
+	size_t len = strlen ( goto_label );
224 225
 
225 226
 	if ( line[0] != ':' )
226 227
 		return -ENOENT;
227
-	if ( strcmp ( goto_label, &line[1] ) != 0 )
228
+
229
+	if ( strncmp ( goto_label, &line[1], len ) != 0 )
230
+		return -ENOENT;
231
+
232
+	if ( line[ 1 + len ] && ! isspace ( line[ 1 + len ] ) )
228 233
 		return -ENOENT;
234
+
229 235
 	return 0;
230 236
 }
231 237
 

Loading…
İptal
Kaydet