diff options
author | Wenxuan Zhao <viz@linux.com> | 2020-04-18 07:27:39 -0700 |
---|---|---|
committer | David Crawshaw <crawshaw@tailscale.com> | 2020-05-02 00:49:10 +1000 |
commit | 75a41b24ad2937169a6b4d0a2909dac1ffff726f (patch) | |
tree | 769e1a22eae04d8b0f08d864d5bba80b0473ebc3 /device/uapi.go | |
parent | a4657f996d98378c06cc7da4d2c69539c19dae32 (diff) | |
download | wireguard-go-75a41b24ad2937169a6b4d0a2909dac1ffff726f.tar.gz wireguard-go-75a41b24ad2937169a6b4d0a2909dac1ffff726f.zip |
device: add nil check before convert typed error back
Since errors.As(err, target) returns false when err is nil,
which cause status set to 1 when no error occurs for Ipc{Get,Set}Operation.
Signed-off-by: Wenxuan Zhao <viz@linux.com>
Diffstat (limited to '')
-rw-r--r-- | device/uapi.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/device/uapi.go b/device/uapi.go index 1671faa..1080ca1 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -423,7 +423,7 @@ func (device *Device) IpcHandle(socket net.Conn) { switch op { case "set=1\n": err = device.IpcSetOperation(buffered.Reader) - if !errors.As(err, &status) { + if err != nil && !errors.As(err, &status) { // should never happen device.log.Error.Println("Invalid UAPI error:", err) status = &IPCError{1} @@ -431,7 +431,7 @@ func (device *Device) IpcHandle(socket net.Conn) { case "get=1\n": err = device.IpcGetOperation(buffered.Writer) - if !errors.As(err, &status) { + if err != nil && !errors.As(err, &status) { // should never happen device.log.Error.Println("Invalid UAPI error:", err) status = &IPCError{1} |