summaryrefslogtreecommitdiffstats
path: root/src/image
diff options
context:
space:
mode:
authorMichael Brown2009-02-16 01:30:48 +0100
committerMichael Brown2009-02-16 01:30:48 +0100
commit24e948f030405df945e7c0290793586d6152b5ed (patch)
treefc0f6c46b375b761204101e74755042e987c269b /src/image
parent[image] Allow multiple embedded images (diff)
downloadipxe-24e948f030405df945e7c0290793586d6152b5ed.tar.gz
ipxe-24e948f030405df945e7c0290793586d6152b5ed.tar.xz
ipxe-24e948f030405df945e7c0290793586d6152b5ed.zip
[image] Avoid claiming zero-length images as valid
Both the script and PXE images types will claim a zero-length image. Inhibit this to avoid end-user surprises.
Diffstat (limited to 'src/image')
-rw-r--r--src/image/script.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/image/script.c b/src/image/script.c
index 749131d6..fe722885 100644
--- a/src/image/script.c
+++ b/src/image/script.c
@@ -94,6 +94,12 @@ static int script_load ( struct image *image ) {
static const char magic[] = "#!gpxe\n";
char test[ sizeof ( magic ) - 1 ];
+ /* Sanity check */
+ if ( image->len < sizeof ( test ) ) {
+ DBG ( "Too short to be a script\n" );
+ return -ENOEXEC;
+ }
+
/* Check for magic signature */
copy_from_user ( test, image->data, 0, sizeof ( test ) );
if ( memcmp ( test, magic, sizeof ( test ) ) != 0 ) {