File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
credentials/alts/internal/conn Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,12 @@ func (p *conn) Read(b []byte) (n int, err error) {
166166 panic (fmt .Sprintf ("protected buffer length shorter than expected: %d vs %d" , len (p .protected ), MsgLenFieldSize ))
167167 }
168168 oldProtectedBuf := p .protected
169- p .protected = make ([]byte , int (length )+ MsgLenFieldSize )
169+ // The new buffer must be able to hold the message length header
170+ // and the entire message.
171+ requiredCapacity := int (length ) + MsgLenFieldSize
172+ p .protected = make ([]byte , requiredCapacity )
173+ // Copy the contents of the old buffer and set the length of the
174+ // new buffer to the number of bytes already read.
170175 copy (p .protected , oldProtectedBuf )
171176 p .protected = p .protected [:len (oldProtectedBuf )]
172177 }
You can’t perform that action at this time.
0 commit comments