[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>
This commit is contained in:
@@ -155,6 +155,14 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
|
||||
get_cached_info->Buffer.segment,
|
||||
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 ) {
|
||||
|
||||
Reference in New Issue
Block a user