tendermint / go-amino

Protobuf3 with Interface support - Designed for blockchains (deterministic, upgradeable, fast, and compact)
Other
260 stars 84 forks source link

values of type "[][]byte" are lost when marshalling #286

Open rickyyangz opened 4 years ago

rickyyangz commented 4 years ago

The latest PR (https://github.com/tendermint/go-amino/pull/283) introduced a bug that as the title described. So multidimensional byte slices/arrays will be marshalled to empty bytes.

I wrote a testcase

func TestMultidimensionalByteSlice(t *testing.T) {
    arr := [2][2]byte{
        [2]byte{1, 2},
        [2]byte{3, 4}}

    bz, err := cdc.MarshalBinaryBare(arr)
    assert.NoError(t, err)
    t.Log(bz)
    var a [][]byte
    cdc.UnmarshalBinaryBare(bz,&a)
    t.Log(a)
}

the result is

=== RUN   TestMultidimensionalByteSlice
--- PASS: TestMultidimensionalByteSlice (0.00s)
    proto3_compat_test.go:136: [10]
    proto3_compat_test.go:139: []
PASS

BTW, I submitted a report to the hackerone bug bounty program, but the response is not very timely, So I create an issue here.

zmanian commented 4 years ago

This bug doesn't appear to have any security implications so would be out of scope for the hackerone bug bounty.

I'm looking into if we can potentially do a bug release to fix this while we work on the full protobuf compatibility PRs

zmanian commented 4 years ago

This test case passes on the latest release v0.15 but does not pass in master. master is work in progress towards more complete protobuf compatibility.