diff options
author | Michael Brown | 2009-02-16 01:30:48 +0100 |
---|---|---|
committer | Michael Brown | 2009-02-16 01:30:48 +0100 |
commit | 24e948f030405df945e7c0290793586d6152b5ed (patch) | |
tree | fc0f6c46b375b761204101e74755042e987c269b /src/image | |
parent | [image] Allow multiple embedded images (diff) | |
download | ipxe-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.c | 6 |
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 ) { |