THRIFT-2891 binary data may cause a failure with JSON transport under specific circumstances
Client: Go
Patch: Jens Geyer
diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go
index ab4e983..6c43c56 100644
--- a/lib/go/thrift/simple_json_protocol.go
+++ b/lib/go/thrift/simple_json_protocol.go
@@ -909,6 +909,12 @@
}
line2 := line[0 : len(line)-1]
l := len(line2)
+ if (l % 4) != 0 {
+ pad := 4 - ( l % 4)
+ fill := [...]byte { '=', '=', '='}
+ line2 = append( line2, fill[:pad]...)
+ l = len(line2)
+ }
output := make([]byte, base64.StdEncoding.DecodedLen(l))
n, err := base64.StdEncoding.Decode(output, line2)
return output[0:n], NewTProtocolException(err)