]> Cypherpunks repositories - gostls13.git/commit
encoding/base64: do not slice past output unnecessarily
authorRuss Cox <rsc@golang.org>
Fri, 1 Mar 2019 17:03:41 +0000 (12:03 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 5 Mar 2019 18:37:55 +0000 (18:37 +0000)
commita125bdb49b9aa96f3185ae4dfcc0f6d13b998724
treeb2742657a8554224c4b5b59709468b293dbd96c9
parent2f8d2427d9751ab5ebdc64ec68ee8e2c0252d8d4
encoding/base64: do not slice past output unnecessarily

Base64-encoding 32 bytes results in a 44-byte string.
While in general a 44-byte string might decode to 33 bytes,
if you take a 44-byte string that actually only encodes 32 bytes,
and you try to decode it into 32 bytes, that should succeed.
Instead it fails trying to do a useless dst[33:] slice operation.
Delete that slice operation.

Noticed while preparing CL 156322.

Change-Id: I8024bf28a65e2638675b980732b2ff91c66c62cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/164628
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/encoding/base64/base64.go
src/encoding/base64/base64_test.go