credentials/alts: Set the handshake extra slice correctly (#3222)

This commit is contained in:
Cesar Ghali 2019-12-03 11:01:32 -08:00 committed by GitHub
parent 4b2104f1fb
commit 1e36139a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -339,6 +339,7 @@ func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []b
// Append extra bytes from the previous interaction with the // Append extra bytes from the previous interaction with the
// handshaker service with the current buffer read from conn. // handshaker service with the current buffer read from conn.
p := append(extra, buf[:n]...) p := append(extra, buf[:n]...)
// From here on, p and extra point to the same slice.
resp, err = h.accessHandshakerService(&altspb.HandshakerReq{ resp, err = h.accessHandshakerService(&altspb.HandshakerReq{
ReqOneof: &altspb.HandshakerReq_Next{ ReqOneof: &altspb.HandshakerReq_Next{
Next: &altspb.NextHandshakeMessageReq{ Next: &altspb.NextHandshakeMessageReq{
@ -350,11 +351,7 @@ func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []b
return nil, nil, err return nil, nil, err
} }
// Set extra based on handshaker service response. // Set extra based on handshaker service response.
if n == 0 { extra = p[resp.GetBytesConsumed():]
extra = nil
} else {
extra = buf[resp.GetBytesConsumed():n]
}
} }
} }