««« backport
95e67cc5fa08
encoding/base64: fix panic when input len is not a multiple of 4
Fixes #3442.
R=for.go.yong, dsymonds, sougou, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/
5975052
»»»
if in == '=' && j >= 2 && len(src) < 4 {
// We've reached the end and there's
// padding
+ if len(src) == 0 && j == 2 {
+ // not enough padding
+ return n, false, CorruptInputError(len(osrc))
+ }
if len(src) > 0 && src[0] != '=' {
+ // incorrect padding
return n, false, CorruptInputError(len(osrc) - len(src) - 1)
}
dlen = j
{"AAA=AAAA", 3},
{"AAAAA", 4},
{"AAAAAA", 4},
+ {"A=", 1},
+ {"AA=", 3},
+ {"AAAAAA=", 7},
}
for _, e := range examples {