From: Ben Pfaff Date: Mon, 9 Feb 2009 17:57:53 +0000 (-0800) Subject: netdev: fix segfault in lookup_netdev(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f259290e08dd68521c8f9bb1973b763f05ceac98;p=openvswitch netdev: fix segfault in lookup_netdev(). svec_find() returns SIZE_MAX, not 0, when the specified name cannot be found. Don't dereference the names array in this case. Fixes a segfault that commonly occurred when secchan was started by vswitchd. --- diff --git a/lib/netdev.c b/lib/netdev.c index 8cf778f3..1dbc7630 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1113,7 +1113,7 @@ static const char * lookup_netdev(const struct netdev_monitor *mon, const char *name) { size_t idx = svec_find(&mon->netdevs, name); - return idx ? mon->netdevs.names[idx] : NULL; + return idx != SIZE_MAX ? mon->netdevs.names[idx] : NULL; } static const char *