Fix invalid pad length [v3] (#413)

* Update filter_aesv3.go
This commit is contained in:
Gunnsteinn Hall 2019-04-15 15:59:23 +00:00 committed by GitHub
parent f8ac397bdf
commit 01f3ac17b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,10 +140,9 @@ func (filterAES) DecryptBytes(buf []byte, okey []byte) ([]byte, error) {
}
// The padded length is indicated by the last values. Remove those.
padLen := int(buf[len(buf)-1])
if padLen >= len(buf) {
common.Log.Debug("Illegal pad length")
if padLen > len(buf) {
common.Log.Debug("Illegal pad length (%d > %d)", padLen, len(buf))
return buf, fmt.Errorf("invalid pad length")
}
buf = buf[:len(buf)-padLen]