Skip to content

Commit

Permalink
fix: PSK extension w/o session cache crashing (#177)
Browse files Browse the repository at this point in the history
Fixes a bug causing client to crash (SIGSEGV) WHEN PSK extension is set with empty session cache AND server sends HelloRetryRequest.
  • Loading branch information
gaukas authored Mar 30, 2023
1 parent 3721531 commit 7aa684a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions u_tls_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,9 @@ type FakePreSharedKeyExtension struct {
}

func (e *FakePreSharedKeyExtension) writeToUConn(uc *UConn) error {
if session, ok := uc.config.ClientSessionCache.Get(clientSessionCacheKey(uc.conn.RemoteAddr(), uc.config)); !ok || session == nil {
return nil // don't write the extension if there is no session
}
uc.HandshakeState.Hello.PskIdentities = e.PskIdentities
uc.HandshakeState.Hello.PskBinders = e.PskBinders
return nil
Expand Down

0 comments on commit 7aa684a

Please # to comment.