summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/interface/pxe/pxe_preboot.c
diff options
context:
space:
mode:
authorMichael Brown2011-12-08 03:35:23 +0100
committerMichael Brown2011-12-08 03:35:23 +0100
commitfaf50e8fa39e4ff3a64418328bedcde6a89a77f2 (patch)
tree8a765c6d125d1a6eb33ce3786f8fc46e4172b2cc /src/arch/i386/interface/pxe/pxe_preboot.c
parent[lotest] Accept non-loopback packets during test (diff)
downloadipxe-faf50e8fa39e4ff3a64418328bedcde6a89a77f2.tar.gz
ipxe-faf50e8fa39e4ff3a64418328bedcde6a89a77f2.tar.xz
ipxe-faf50e8fa39e4ff3a64418328bedcde6a89a77f2.zip
[pxe] Check for a valid PXE network device when applicable
Very nasty things can happen if a NULL network device is used. Check that pxe_netdev is non-NULL at the applicable entry points, so that this type of problem gets reported to the caller rather than being allowed to crash the system. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/interface/pxe/pxe_preboot.c')
-rw-r--r--src/arch/i386/interface/pxe/pxe_preboot.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/arch/i386/interface/pxe/pxe_preboot.c b/src/arch/i386/interface/pxe/pxe_preboot.c
index 131ce8a8f..4a9f7ed56 100644
--- a/src/arch/i386/interface/pxe/pxe_preboot.c
+++ b/src/arch/i386/interface/pxe/pxe_preboot.c
@@ -156,6 +156,14 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
get_cached_info->Buffer.offset, get_cached_info->BufferSize );
/* Sanity check */
+ if ( ! pxe_netdev ) {
+ DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO called with no "
+ "network device\n" );
+ get_cached_info->Status = PXENV_STATUS_UNDI_INVALID_STATE;
+ return PXENV_EXIT_FAILURE;
+ }
+
+ /* Sanity check */
idx = ( get_cached_info->PacketType - 1 );
if ( idx >= NUM_CACHED_INFOS ) {
DBGC ( &pxe_netdev, " bad PacketType %d\n",