GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 2585b23f authored by David Fifield's avatar David Fifield
Browse files

In lib.Handler, close resources even in case of an error.

This is issue UCB-02-001 from the 2021 security audit of Turbo Tunnel by
Cure53.

Closes #40042.
parent eff73c30
Pipeline #5225 passed with stage
in 6 minutes and 7 seconds
......@@ -102,6 +102,10 @@ func Handler(socks net.Conn, tongue Tongue) error {
if err != nil {
return err
}
defer func() {
snowflakes.End()
log.Printf("---- Handler: end collecting snowflakes ---")
}()
// Use a real logger to periodically output how much traffic is happening.
snowflakes.BytesLogger = NewBytesSyncLogger()
......@@ -115,23 +119,25 @@ func Handler(socks net.Conn, tongue Tongue) error {
if err != nil {
return err
}
defer func() {
pconn.Close()
sess.Close()
log.Printf("---- Handler: discarding finished session ---")
}()
// On the smux session we overlay a stream.
stream, err := sess.OpenStream()
if err != nil {
return err
}
defer stream.Close()
defer func() {
stream.Close()
log.Printf("---- Handler: closed stream %v ---", stream.ID())
}()
log.Printf("---- Handler: begin stream %v ---", stream.ID())
// Begin exchanging data.
log.Printf("---- Handler: begin stream %v ---", stream.ID())
copyLoop(socks, stream)
log.Printf("---- Handler: closed stream %v ---", stream.ID())
snowflakes.End()
log.Printf("---- Handler: end collecting snowflakes ---")
pconn.Close()
sess.Close()
log.Printf("---- Handler: discarding finished session ---")
return nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment