summaryrefslogtreecommitdiff
path: root/gpxe/src/image/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/image/script.c')
-rw-r--r--gpxe/src/image/script.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gpxe/src/image/script.c b/gpxe/src/image/script.c
index 2d242746..0835ecb5 100644
--- a/gpxe/src/image/script.c
+++ b/gpxe/src/image/script.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
/**
* @file
*
@@ -25,6 +27,7 @@
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
#include <errno.h>
#include <gpxe/image.h>
@@ -88,8 +91,8 @@ static int script_exec ( struct image *image ) {
* @ret rc Return status code
*/
static int script_load ( struct image *image ) {
- static const char magic[] = "#!gpxe\n";
- char test[ sizeof ( magic ) - 1 ];
+ static const char magic[] = "#!gpxe";
+ char test[ sizeof ( magic ) - 1 /* NUL */ + 1 /* terminating space */];
/* Sanity check */
if ( image->len < sizeof ( test ) ) {
@@ -99,7 +102,8 @@ 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 ) ) != 0 ) {
+ if ( ( memcmp ( test, magic, ( sizeof ( test ) - 1 ) ) != 0 ) ||
+ ! isspace ( test[ sizeof ( test ) - 1 ] ) ) {
DBG ( "Invalid magic signature\n" );
return -ENOEXEC;
}