[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.
This commit is contained in:
Michael Brown
2009-02-16 00:30:48 +00:00
parent 076154a1c6
commit 24e948f030
2 changed files with 12 additions and 0 deletions

View File

@@ -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 ) {