|
@@ -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
|
}
|