1
0
mirror of https://github.com/golang/go synced 2024-11-20 00:44:45 -07:00

encoding/ascii85: fix panic caused by special case

Special case for encoding 4 zeros as 'z' didn't
update source slice, causing 'index out of bounds'
panic in destination slice.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5970078
This commit is contained in:
Dmitry Chestnykh 2012-04-04 09:52:42 -04:00 committed by Russ Cox
parent 5496e94187
commit ac51c1384a
2 changed files with 6 additions and 0 deletions

View File

@ -57,6 +57,7 @@ func Encode(dst, src []byte) int {
if v == 0 && len(src) >= 4 {
dst[0] = 'z'
dst = dst[1:]
src = src[4:]
n++
continue
}

View File

@ -28,6 +28,11 @@ var pairs = []testpair{
"l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G\n" +
">uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c\n",
},
// Special case when shortening !!!!! to z.
{
"\000\000\000\000",
"z",
},
}
var bigtest = pairs[len(pairs)-1]