summaryrefslogtreecommitdiffstats
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown2010-05-22 01:27:10 +0200
committerMichael Brown2010-05-22 01:27:10 +0200
commit13dfe2cf51508601ddd605733dfd56ed15a10e60 (patch)
tree2b76c225345bb1aa8ce98937fb51ef4d52b822ae /src/image
parent[pxe] Treat PXENV_RESTART_TFTP as unreturnable (diff)
downloadipxe-13dfe2cf51508601ddd605733dfd56ed15a10e60.tar.gz
ipxe-13dfe2cf51508601ddd605733dfd56ed15a10e60.tar.xz
ipxe-13dfe2cf51508601ddd605733dfd56ed15a10e60.zip
[script] Accept "#!gpxe" as well as "#!ipxe" as a script magic marker
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/script.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/image/script.c b/src/image/script.c
index 61f5a997..b65fa061 100644
--- a/src/image/script.c
+++ b/src/image/script.c
@@ -91,8 +91,12 @@ static int script_exec ( struct image *image ) {
* @ret rc Return status code
*/
static int script_load ( struct image *image ) {
- static const char magic[] = "#!ipxe";
- char test[ sizeof ( magic ) - 1 /* NUL */ + 1 /* terminating space */];
+ static const char ipxe_magic[] = "#!ipxe";
+ static const char gpxe_magic[] = "#!gpxe";
+ linker_assert ( sizeof ( ipxe_magic ) == sizeof ( gpxe_magic ),
+ magic_size_mismatch );
+ char test[ sizeof ( ipxe_magic ) - 1 /* NUL */
+ + 1 /* terminating space */];
/* Sanity check */
if ( image->len < sizeof ( test ) ) {
@@ -102,8 +106,9 @@ static int script_load ( struct image *image ) {
/* Check for magic signature */
copy_from_user ( test, image->data, 0, sizeof ( test ) );
- if ( ( memcmp ( test, magic, ( sizeof ( test ) - 1 ) ) != 0 ) ||
- ! isspace ( test[ sizeof ( test ) - 1 ] ) ) {
+ if ( ! ( ( ( memcmp ( test, ipxe_magic, sizeof ( test ) - 1 ) == 0 ) ||
+ ( memcmp ( test, gpxe_magic, sizeof ( test ) - 1 ) == 0 )) &&
+ isspace ( test[ sizeof ( test ) - 1 ] ) ) ) {
DBG ( "Invalid magic signature\n" );
return -ENOEXEC;
}