Skip to content

Commit 897410b

Browse files
committed
Avoid crash when tunnel cannot be opened
When client.Tunnel() returns an error, then the returned stream is invalid and must not be used. Signed-off-by: Jan Dubois <[email protected]>
1 parent 6cd896f commit 897410b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pkg/portfwd/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func HandleTCPConnection(ctx context.Context, client *guestagentclient.GuestAgen
2121
stream, err := client.Tunnel(ctx)
2222
if err != nil {
2323
logrus.Errorf("could not open tcp tunnel for id: %s error:%v", id, err)
24+
return
2425
}
2526

2627
g, _ := errgroup.WithContext(ctx)
@@ -54,6 +55,7 @@ func HandleUDPConnection(ctx context.Context, client *guestagentclient.GuestAgen
5455
stream, err := client.Tunnel(ctx)
5556
if err != nil {
5657
logrus.Errorf("could not open udp tunnel for id: %s error:%v", id, err)
58+
return
5759
}
5860

5961
g, _ := errgroup.WithContext(ctx)

0 commit comments

Comments
 (0)