Skip to content

fix dial checking the wrong error #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tailscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func TsnetDial(sd C.int, network, addr *C.char, connOut *C.int) C.int {
if err != nil {
return s.recErr(err)
}
if newConn(s, netConn, connOut); err != nil {
if err := newConn(s, netConn, connOut); err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good fix. The original code was checking the wrong error variable - it was using the outer scope 'err' from the s.s.Dial call instead of capturing the error returned by newConn(). This could have led to silently ignoring errors from newConn() while incorrectly reporting errors from the Dial operation that had actually succeeded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it was falsely reporting errors for something that succeeds, but it possibly wasn't reporting errors for failures in newConn

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crawshaw I think this was yours.

return s.recErr(err)
}
return 0
Expand Down