[tor-bugs] #31794 [Circumvention/Snowflake]: Errors swallowed
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Sep 26 17:13:14 UTC 2019
#31794: Errors swallowed
-------------------------------------+------------------------------
Reporter: sah | Owner: (none)
Type: defect | Status: needs_review
Priority: Medium | Milestone:
Component: Circumvention/Snowflake | Version:
Severity: Normal | Resolution:
Keywords: | Actual Points:
Parent ID: | Points:
Reviewer: cohosh | Sponsor:
-------------------------------------+------------------------------
Description changed by dcf:
Old description:
> I've run golangci-lint against the current code and there are a number of
> errcheck, golint, and govet issues raised.
>
> An example is in the directory snowflake/server-webrtc and is pasted
> below. The error messages are trivial to update to meet with conventions.
>
> But I have a query about how to deal with the errors not being handled.
> For example pw.CloseWithError(err) can generate an error, should that
> error merely be logged, or should some other action take place (an error
> sent to the user perhaps?)
>
> http.go:26:10: Error return value of `w.Write` is not checked (errcheck)
> w.Write([]byte(`HTTP signaling channel
> ^
> http.go:60:9: Error return value of `w.Write` is not checked (errcheck)
> w.Write([]byte(pc.LocalDescription().Serialize()))
> ^
> snowflake.go:32:10: Error return value of `io.Copy` is not checked
> (errcheck)
> io.Copy(b, a)
> ^
> snowflake.go:36:10: Error return value of `io.Copy` is not checked
> (errcheck)
> io.Copy(a, b)
> ^
> snowflake.go:144:22: Error return value of `pw.CloseWithError` is not
> checked (errcheck)
> pw.CloseWithError(err)
> ^
> snowflake.go:156:13: Error return value of `pc.Destroy` is not checked
> (errcheck)
> pc.Destroy()
> ^
> snowflake.go:164:13: Error return value of `pc.Destroy` is not checked
> (errcheck)
> pc.Destroy()
> ^
> snowflake.go:169:13: Error return value of `pc.Destroy` is not checked
> (errcheck)
> pc.Destroy()
> ^
> snowflake.go:225:19: Error return value of `pt.SmethodError` is not
> checked (errcheck)
> pt.SmethodError(bindaddr.MethodName, "no such
> method")
> ^
> snowflake.go:239:11: Error return value of `io.Copy` is not checked
> (errcheck)
> io.Copy(ioutil.Discard, os.Stdin)
> ^
> snowflake.go:82:20: error strings should not be capitalized or end with
> punctuation or a newline (golint)
> return fmt.Errorf("SetDeadline not implemented")
> ^
> snowflake.go:86:20: error strings should not be capitalized or end with
> punctuation or a newline (golint)
> return fmt.Errorf("SetReadDeadline not implemented")
> ^
> snowflake.go:90:20: error strings should not be capitalized or end with
> punctuation or a newline (golint)
> return fmt.Errorf("SetWriteDeadline not implemented")
> ^
> snowflake.go:230:24: should drop = 0 from declaration of var numHandlers;
> it is the zero value (golint)
> var numHandlers int = 0
> ^
> snowflake.go:142:7: shadow: declaration of "err" shadows declaration at
> line 116 (govet)
> n, err := pw.Write(msg)
> ^
> snowflake.go:193:6: shadow: declaration of "err" shadows declaration at
> line 183 (govet)
> f, err := os.OpenFile(logFilename,
> os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
New description:
I've run golangci-lint against the current code and there are a number of
errcheck, golint, and govet issues raised.
An example is in the directory snowflake/server-webrtc and is pasted
below. The error messages are trivial to update to meet with conventions.
But I have a query about how to deal with the errors not being handled.
For example pw.CloseWithError(err) can generate an error, should that
error merely be logged, or should some other action take place (an error
sent to the user perhaps?)
{{{
http.go:26:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(`HTTP signaling channel
^
http.go:60:9: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(pc.LocalDescription().Serialize()))
^
snowflake.go:32:10: Error return value of `io.Copy` is not checked
(errcheck)
io.Copy(b, a)
^
snowflake.go:36:10: Error return value of `io.Copy` is not checked
(errcheck)
io.Copy(a, b)
^
snowflake.go:144:22: Error return value of `pw.CloseWithError` is not
checked (errcheck)
pw.CloseWithError(err)
^
snowflake.go:156:13: Error return value of `pc.Destroy` is not checked
(errcheck)
pc.Destroy()
^
snowflake.go:164:13: Error return value of `pc.Destroy` is not checked
(errcheck)
pc.Destroy()
^
snowflake.go:169:13: Error return value of `pc.Destroy` is not checked
(errcheck)
pc.Destroy()
^
snowflake.go:225:19: Error return value of `pt.SmethodError` is not
checked (errcheck)
pt.SmethodError(bindaddr.MethodName, "no such
method")
^
snowflake.go:239:11: Error return value of `io.Copy` is not checked
(errcheck)
io.Copy(ioutil.Discard, os.Stdin)
^
snowflake.go:82:20: error strings should not be capitalized or end with
punctuation or a newline (golint)
return fmt.Errorf("SetDeadline not implemented")
^
snowflake.go:86:20: error strings should not be capitalized or end with
punctuation or a newline (golint)
return fmt.Errorf("SetReadDeadline not implemented")
^
snowflake.go:90:20: error strings should not be capitalized or end with
punctuation or a newline (golint)
return fmt.Errorf("SetWriteDeadline not implemented")
^
snowflake.go:230:24: should drop = 0 from declaration of var numHandlers;
it is the zero value (golint)
var numHandlers int = 0
^
snowflake.go:142:7: shadow: declaration of "err" shadows declaration at
line 116 (govet)
n, err := pw.Write(msg)
^
snowflake.go:193:6: shadow: declaration of "err" shadows declaration at
line 183 (govet)
f, err := os.OpenFile(logFilename,
os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
}}}
--
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31794#comment:12>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list