Browse Source

[script] Accept "#!gpxe" as well as "#!ipxe" as a script magic marker

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
13dfe2cf51
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      src/image/script.c

+ 9
- 4
src/image/script.c View File

@@ -91,8 +91,12 @@ static int script_exec ( struct image *image ) {
91 91
  * @ret rc		Return status code
92 92
  */
93 93
 static int script_load ( struct image *image ) {
94
-	static const char magic[] = "#!ipxe";
95
-	char test[ sizeof ( magic ) - 1 /* NUL */ + 1 /* terminating space */];
94
+	static const char ipxe_magic[] = "#!ipxe";
95
+	static const char gpxe_magic[] = "#!gpxe";
96
+	linker_assert ( sizeof ( ipxe_magic ) == sizeof ( gpxe_magic ),
97
+			magic_size_mismatch );
98
+	char test[ sizeof ( ipxe_magic ) - 1 /* NUL */
99
+		   + 1 /* terminating space */];
96 100
 
97 101
 	/* Sanity check */
98 102
 	if ( image->len < sizeof ( test ) ) {
@@ -102,8 +106,9 @@ static int script_load ( struct image *image ) {
102 106
 
103 107
 	/* Check for magic signature */
104 108
 	copy_from_user ( test, image->data, 0, sizeof ( test ) );
105
-	if ( ( memcmp ( test, magic, ( sizeof ( test ) - 1 ) ) != 0 ) ||
106
-	     ! isspace ( test[ sizeof ( test ) - 1 ] ) ) {
109
+	if ( ! ( ( ( memcmp ( test, ipxe_magic, sizeof ( test ) - 1 ) == 0 ) ||
110
+		   ( memcmp ( test, gpxe_magic, sizeof ( test ) - 1 ) == 0 )) &&
111
+		 isspace ( test[ sizeof ( test ) - 1 ] ) ) ) {
107 112
 		DBG ( "Invalid magic signature\n" );
108 113
 		return -ENOEXEC;
109 114
 	}

Loading…
Cancel
Save