From: Michael Brown Date: Tue, 29 Mar 2016 19:57:03 +0000 (+0100) Subject: [netdevice] Return ENOENT for an unknown bus type X-Git-Tag: v1.20.1~489 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70509e6a03e8e307c579ca5ebafa591f6741db6f;p=thirdparty%2Fipxe.git [netdevice] Return ENOENT for an unknown bus type It is possible for the preloaded UNDI device to end up with no specified bus type, since it may not be recognised as either a PCI or an ISAPnP device. This will result in a bus type value of zero, which currently results in NULL being treated as a string pointer by netdev_fetch_bustype(). Fix by returning ENOENT if an unknown bus type is specified. Reported-by: Todd Stansell Signed-off-by: Michael Brown --- diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c index c4fd36941..7d893a126 100644 --- a/src/net/netdev_settings.c +++ b/src/net/netdev_settings.c @@ -141,7 +141,8 @@ static int netdev_fetch_bustype ( struct net_device *netdev, void *data, assert ( desc->bus_type < ( sizeof ( bustypes ) / sizeof ( bustypes[0] ) ) ); bustype = bustypes[desc->bus_type]; - assert ( bustype != NULL ); + if ( ! bustype ) + return -ENOENT; strncpy ( data, bustype, len ); return strlen ( bustype ); }