Skip to content

Commit

Permalink
apply @distractedm1nd patch
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp authored and distractedm1nd committed Jun 16, 2023
1 parent a29ac50 commit 6280735
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ func parseNamespace(param string) (namespace.ID, error) {
if err != nil {
return nil, err
}
} else if len(nID) < appns.NamespaceSize {
return nil, fmt.Errorf("passed namespace is too large")
}
return nID, nil
}
Expand Down
28 changes: 21 additions & 7 deletions cmd/celestia/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,27 @@ func Test_parseNamespace(t *testing.T) {
},
wantErr: false,
},
// HACKHACK: This test case is disabled because it fails.
// {
// name: "11 byte hex encoded namespace returns error",
// param: "0x42690c204d39600fddd3a3",
// want: namespace.ID{},
// wantErr: true,
// },
{
name: "11 byte hex encoded namespace returns error",
param: "0x42690c204d39600fddd3a3",
want: namespace.ID{},
wantErr: true,
},
{
name: "10 byte base64 encoded namespace",
param: "QmkMIE05YA/d0w==",
want: namespace.ID{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x42, 0x69, 0xc, 0x20, 0x4d, 0x39, 0x60, 0xf, 0xdd, 0xd3,
},
wantErr: false,
},
{
name: "not base64 or hex encoded namespace returns error",
param: "5748493939429",
want: namespace.ID{},
wantErr: true,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 6280735

Please sign in to comment.