Skip to content

Commit

Permalink
Fix #76: Write call overwrite err returned by Read.
Browse files Browse the repository at this point in the history
Thanks for defia pointing out this bug.
  • Loading branch information
cyfdecyf committed Feb 12, 2015
1 parent 46c507b commit 55f57aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion shadowsocks/pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func PipeThenClose(src, dst net.Conn, timeoutOpt int) {
// read may return EOF with n > 0
// should always process n > 0 bytes before handling error
if n > 0 {
if _, err = dst.Write(buf[0:n]); err != nil {
// Note: avoid overwrite err returned by Read.
if _, err := dst.Write(buf[0:n]); err != nil {
Debug.Println("write:", err)
break
}
Expand Down

0 comments on commit 55f57aa

Please sign in to comment.