]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Return ENOENT for an unknown bus type
authorMichael Brown <mcb30@ipxe.org>
Tue, 29 Mar 2016 19:57:03 +0000 (20:57 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 29 Mar 2016 19:59:30 +0000 (20:59 +0100)
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 <todd@stansell.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/netdev_settings.c

index c4fd369415739f586f906c83a38a28bde972f49e..7d893a126582913711c5f8600dc05851df7ae21f 100644 (file)
@@ -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 );
 }