mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-09-18 20:57:50 +02:00
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>
This commit is contained in:
parent
a4657f996d
commit
75a41b24ad
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user