summaryrefslogtreecommitdiffhomepage
path: root/device/uapi.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-01-26 10:35:25 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 22:40:10 +0100
commit37efdcaccfb16e47137728b5462c90d0b2ae8460 (patch)
tree65742a085905331b0e8c7501ac1c0dbc64ff2854 /device/uapi.go
parentd3a2b74df28ea7d7e90918c4431a38853990ce72 (diff)
device: fix shadowing of err in IpcHandle
The declaration of err in nextByte, err := buffered.ReadByte shadows the declaration of err in op, err := buffered.ReadString('\n') above. As a result, the assignments to err in err = ipcErrorf(ipc.IpcErrorInvalid, "trailing character in UAPI get: %c", nextByte) and in err = device.IpcGetOperation(buffered.Writer) do not modify the correct err variable. Found by staticcheck. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/uapi.go')
-rw-r--r--device/uapi.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/device/uapi.go b/device/uapi.go
index 2110a67..277c02f 100644
--- a/device/uapi.go
+++ b/device/uapi.go
@@ -403,7 +403,8 @@ func (device *Device) IpcHandle(socket net.Conn) {
case "set=1\n":
err = device.IpcSetOperation(buffered.Reader)
case "get=1\n":
- nextByte, err := buffered.ReadByte()
+ var nextByte byte
+ nextByte, err = buffered.ReadByte()
if err != nil {
return
}