rpc: fix potential getblock handling problem, add a test for it

It should only accept hex strings and numbers, anything else is wrong.
This commit is contained in:
Roman Khimov 2019-11-26 13:31:11 +03:00
parent 1c883cc819
commit 3843451ec4
2 changed files with 6 additions and 1 deletions

View file

@ -141,7 +141,7 @@ Methods:
break Methods break Methods
} }
hash = s.chain.GetHeaderHash(num) hash = s.chain.GetHeaderHash(num)
case defaultT: default:
resultsErr = errInvalidParams resultsErr = errInvalidParams
break Methods break Methods
} }

View file

@ -126,6 +126,11 @@ var rpcTestCases = map[string][]rpcTestCase{
params: `[]`, params: `[]`,
fail: true, fail: true,
}, },
{
name: "bad params",
params: `[[]]`,
fail: true,
},
{ {
name: "invalid height", name: "invalid height",
params: `[-1]`, params: `[-1]`,