Fix a potential make len<0

This commit is contained in:
Qian Wang 2019-08-07 17:22:40 +01:00
parent b7549c0664
commit e3de2b9852

View File

@ -89,7 +89,11 @@ func MakeDeobfs(salsaKey [32]byte, payloadCipher cipher.AEAD) Deobfser {
closing := header[8] closing := header[8]
extraLen := header[9] extraLen := header[9]
outputPayload := make([]byte, len(payload)-int(extraLen)) outputLen := len(payload) - int(extraLen)
if outputLen < 0 {
return nil, errors.New("extra length is greater than total payload length")
}
outputPayload := make([]byte, outputLen)
if payloadCipher == nil { if payloadCipher == nil {
copy(outputPayload, payload) copy(outputPayload, payload)