Browse Source

[HCI] Display "Not an executable image" when appropriate

PXE is a catch-all image format with no signature checks.  If an
unsupported image file is loaded, it will be treated as a PXE image.  In
most cases, the image will be too large to be loaded as a PXE image (which
has to fit in base memory), so the error returned to the user will be that
the segment could not fit within the memory region.

Add an explicit check to pxe_image.c to reject images larger than base
memory with ENOEXEC.

Add ENOEXEC to the error string table.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
3475b693b7
2 changed files with 9 additions and 0 deletions
  1. 8
    0
      src/arch/i386/image/pxe_image.c
  2. 1
    0
      src/hci/strerror.c

+ 8
- 0
src/arch/i386/image/pxe_image.c View File

84
 	size_t memsz = image->len;
84
 	size_t memsz = image->len;
85
 	int rc;
85
 	int rc;
86
 
86
 
87
+	/* Images too large to fit in base memory cannot be PXE
88
+	 * images.  We include this check to help prevent unrecognised
89
+	 * images from being marked as PXE images, since PXE images
90
+	 * have no signature we can check against.
91
+	 */
92
+	if ( filesz > ( 0xa0000 - 0x7c00 ) )
93
+		return -ENOEXEC;
94
+
87
 	/* There are no signature checks for PXE; we will accept anything */
95
 	/* There are no signature checks for PXE; we will accept anything */
88
 	if ( ! image->type )
96
 	if ( ! image->type )
89
 		image->type = &pxe_image_type;
97
 		image->type = &pxe_image_type;

+ 1
- 0
src/hci/strerror.c View File

118
 	{ ETIMEDOUT, "Connection timed out" },
118
 	{ ETIMEDOUT, "Connection timed out" },
119
 	{ EPIPE, "Broken pipe" },
119
 	{ EPIPE, "Broken pipe" },
120
 	{ ECANCELED, "Operation cancelled" },
120
 	{ ECANCELED, "Operation cancelled" },
121
+	{ ENOEXEC, "Not an executable image" },
121
 };
122
 };

Loading…
Cancel
Save