Fix Sscanf use in tun_darwin

License: MIT
Signed-off-by: Filippo Valsorda <valsorda@google.com>
This commit is contained in:
Filippo Valsorda 2018-05-20 23:38:58 -04:00 committed by Jason A. Donenfeld
parent 84f52ce0d6
commit 7a527f7c89

View file

@ -100,8 +100,8 @@ func (tun *NativeTun) RoutineRouteListener(tunIfindex int) {
func CreateTUN(name string) (TUNDevice, error) {
ifIndex := -1
if name != "utun" {
fmt.Sscanf(name, "utun%d", &ifIndex)
if ifIndex < 0 {
_, err := fmt.Sscanf(name, "utun%d", &ifIndex)
if err != nil || ifIndex < 0 {
return nil, fmt.Errorf("Interface name must be utun[0-9]*")
}
}