Fixed a bug: That 4096 bytes can all be used to buffer a AES-GCM block

This commit is contained in:
NI
2019-09-20 22:07:09 +08:00
parent cc4f095995
commit 6349d1ede5

View File

@@ -354,7 +354,6 @@ func (s socket) Get(
// Start service
const cipherReadBufSize = 4096
const cipherMaxDataPayloadLen = cipherReadBufSize - 2
cipherReadBuf := [cipherReadBufSize]byte{}
cipherWriteBuf := [cipherReadBufSize]byte{}
@@ -381,7 +380,7 @@ func (s socket) Get(
packageSize <<= 8
packageSize |= uint16(cipherReadBuf[1])
if packageSize <= 0 || packageSize > cipherMaxDataPayloadLen {
if packageSize <= 0 || packageSize > cipherReadBufSize {
return nil, ErrSocketInvalidDataPackage
}