mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-09 00:32:09 -04:00
Fix decode
- Write decoded bytes without padding Signed-off-by: Natalie Arellano <narellano@pivotal.io>
This commit is contained in:
parent
0614fc234f
commit
9a16b6768e
2 changed files with 4 additions and 3 deletions
|
|
@ -203,9 +203,10 @@ func (d *Base64Pipe) ReadFrom(r io.Reader) (int64, error) {
|
|||
func (d *Base64Pipe) Write(p []byte) (int, error) {
|
||||
dst := make([]byte, base64.StdEncoding.DecodedLen(len(p)))
|
||||
|
||||
if _, err := base64.StdEncoding.Decode(dst, p); err != nil {
|
||||
decodedBytes, err := base64.StdEncoding.Decode(dst, p)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return d.w.Write(dst)
|
||||
return d.w.Write(dst[0:decodedBytes])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ func TestUpload(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("error downloading file: %s", err)
|
||||
}
|
||||
downloadedPayload := strings.TrimRight(dest.String(), "\x00")
|
||||
downloadedPayload := dest.String()
|
||||
|
||||
if downloadedPayload != PAYLOAD {
|
||||
t.Fatalf("files are not equal: expected [%s] length: %v, got [%s] length %v", PAYLOAD, len(PAYLOAD), downloadedPayload, len(downloadedPayload))
|
||||
|
|
|
|||
Loading…
Reference in a new issue