Skip to content

Commit

Permalink
dialer: move negotiated extension and copy extension parameters
Browse files Browse the repository at this point in the history
Fixes following issue:
Extensions in Handshake returned from (Dialer) Upgrade contain slices
pointing to memory in buffer already returned to pbufio.ReaderPool.
  • Loading branch information
magicxyyz authored and cristaloleg committed Apr 10, 2023
1 parent 8e2d520 commit 417ec07
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ func matchSelectedExtensions(selected []byte, wanted, received []httphead.Option
if bytes.Equal(option.Name, want.Name) {
// Check parsed extension to be present in client
// requested extensions. We move matched extension
// from client list to avoid allocation.
received = append(received, option)
// from client list to avoid allocation of httphead.Option.Name,
// httphead.Option.Parameters have to be copied from the header
want.Parameters, _ = option.Parameters.Copy(make([]byte, option.Parameters.Size()))
received = append(received, want)
return true
}
}
Expand Down

0 comments on commit 417ec07

Please sign in to comment.