diff options
author | Anand Francis Joseph <anjoseph@redhat.com> | 2023-11-02 22:48:52 +0530 |
---|---|---|
committer | Anand Francis Joseph <anjoseph@redhat.com> | 2023-11-02 22:48:52 +0530 |
commit | 501e9ad99aa3d18b7711d8cea94e0e9b68883b6b (patch) | |
tree | 32097c3bc4bfa6327b71bc5627eea8efd9bc7678 /plumbing/transport/ssh/common.go | |
parent | 6252084d6fd3173aceeecd6765722ae844ddb266 (diff) | |
download | go-git-501e9ad99aa3d18b7711d8cea94e0e9b68883b6b.tar.gz |
plumbing: transport/ssh, Fix nil pointer dereference caused when an unreachable proxy server is set. Fixes #900
Signed-off-by: Anand Francis Joseph <anjoseph@redhat.com>
Diffstat (limited to 'plumbing/transport/ssh/common.go')
-rw-r--r-- | plumbing/transport/ssh/common.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/plumbing/transport/ssh/common.go b/plumbing/transport/ssh/common.go index 1531603..46fda73 100644 --- a/plumbing/transport/ssh/common.go +++ b/plumbing/transport/ssh/common.go @@ -168,7 +168,7 @@ func dial(network, addr string, proxyOpts transport.ProxyOptions, config *ssh.Cl defer cancel() var conn net.Conn - var err error + var dialErr error if proxyOpts.URL != "" { proxyUrl, err := proxyOpts.FullURL() @@ -186,12 +186,12 @@ func dial(network, addr string, proxyOpts transport.ProxyOptions, config *ssh.Cl return nil, fmt.Errorf("expected ssh proxy dialer to be of type %s; got %s", reflect.TypeOf(ctxDialer), reflect.TypeOf(dialer)) } - conn, err = ctxDialer.DialContext(ctx, "tcp", addr) + conn, dialErr = ctxDialer.DialContext(ctx, "tcp", addr) } else { - conn, err = proxy.Dial(ctx, network, addr) + conn, dialErr = proxy.Dial(ctx, network, addr) } - if err != nil { - return nil, err + if dialErr != nil { + return nil, dialErr } c, chans, reqs, err := ssh.NewClientConn(conn, addr, config) |