Handle panic when invalid IP entered in sshd (#296)
This commit is contained in:
parent
50b04413c7
commit
6238f1550b
42
ssh.go
42
ssh.go
|
@ -463,7 +463,12 @@ func sshQueryLighthouse(ifce *Interface, fs interface{}, a []string, w sshd.Stri
|
|||
return w.WriteLine("No vpn ip was provided")
|
||||
}
|
||||
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
@ -483,7 +488,12 @@ func sshCloseTunnel(ifce *Interface, fs interface{}, a []string, w sshd.StringWr
|
|||
return w.WriteLine("No vpn ip was provided")
|
||||
}
|
||||
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
@ -521,7 +531,12 @@ func sshCreateTunnel(ifce *Interface, fs interface{}, a []string, w sshd.StringW
|
|||
return w.WriteLine("No vpn ip was provided")
|
||||
}
|
||||
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
@ -573,7 +588,12 @@ func sshChangeRemote(ifce *Interface, fs interface{}, a []string, w sshd.StringW
|
|||
return w.WriteLine("Address could not be parsed")
|
||||
}
|
||||
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
@ -649,7 +669,12 @@ func sshPrintCert(ifce *Interface, fs interface{}, a []string, w sshd.StringWrit
|
|||
|
||||
cert := ifce.certState.certificate
|
||||
if len(a) > 0 {
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
@ -696,7 +721,12 @@ func sshPrintTunnel(ifce *Interface, fs interface{}, a []string, w sshd.StringWr
|
|||
return w.WriteLine("No vpn ip was provided")
|
||||
}
|
||||
|
||||
vpnIp := ip2int(net.ParseIP(a[0]))
|
||||
parsedIp := net.ParseIP(a[0])
|
||||
if parsedIp == nil {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
||||
vpnIp := ip2int(parsedIp)
|
||||
if vpnIp == 0 {
|
||||
return w.WriteLine(fmt.Sprintf("The provided vpn ip could not be parsed: %s", a[0]))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue