From 1e36139a79057d9e4bc4905a33573d2b1921b078 Mon Sep 17 00:00:00 2001 From: Cesar Ghali Date: Tue, 3 Dec 2019 11:01:32 -0800 Subject: [PATCH] credentials/alts: Set the handshake extra slice correctly (#3222) --- credentials/alts/internal/handshaker/handshaker.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/credentials/alts/internal/handshaker/handshaker.go b/credentials/alts/internal/handshaker/handshaker.go index 49c22c1e8..633c71257 100644 --- a/credentials/alts/internal/handshaker/handshaker.go +++ b/credentials/alts/internal/handshaker/handshaker.go @@ -339,6 +339,7 @@ func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []b // Append extra bytes from the previous interaction with the // handshaker service with the current buffer read from conn. p := append(extra, buf[:n]...) + // From here on, p and extra point to the same slice. resp, err = h.accessHandshakerService(&altspb.HandshakerReq{ ReqOneof: &altspb.HandshakerReq_Next{ Next: &altspb.NextHandshakeMessageReq{ @@ -350,11 +351,7 @@ func (h *altsHandshaker) processUntilDone(resp *altspb.HandshakerResp, extra []b return nil, nil, err } // Set extra based on handshaker service response. - if n == 0 { - extra = nil - } else { - extra = buf[resp.GetBytesConsumed():n] - } + extra = p[resp.GetBytesConsumed():] } }