RPCConsole: Throw when overflowing size_t type for array indices#446
Conversation
|
concept ack |
jarolrod
left a comment
There was a problem hiding this comment.
ACK faa5e17
tested and code review ack. This is a nice catch!
on master:
<- getblock(getbestblockhash(), 1)[tx][22222222222222222222222222222]
-> e3038545d5b68dc61a282f15eb8e3ffbfb50c3f9955380a1fde3c1c858414d38
on PR branch:
<- getblock(getbestblockhash(), 1)[tx][22222222222222222222222222222]
-> Error: Invalid result query
shaavan
left a comment
There was a problem hiding this comment.
ACK faa5e17
Tested on Ubuntu 20.04
This PR allows displaying runtime error for inputs greater than the limit of size_t type.
This is done by using the ToIntegral<size_t> function, which will check the size of the input argument. Earlier, the logic was to check if each character of the input argument is a digit or not without considering the overall length of the input argument.
This is undoubtedly an improvement over the current Master, and I agree with this PR. I am adding the screenshot of input and outputs that I used to test this PR on the GUI console. The test was done on the Signet network.
Screenshots:
| Master (outputs null, without errors) | PR (output error) |
|---|---|
![]() |
![]() |
… type for array indices faa5e17 RPCConsole: Throw when overflowing size_t type for array indices (MarcoFalke) Pull request description: To test: -> `getblock(getbestblockhash(), 1)[tx][22222222222222222222222222222]` Before: <- `868693731dea69a197c13c2cfaa41c9f78fcdeb8ab8e9f8cdf2c9025147ee7d1` (hash of the coinbase tx) After: <- `Error: Invalid result query` ACKs for top commit: jarolrod: ACK faa5e17 shaavan: ACK faa5e17 Tree-SHA512: ddff39aae1c15db45928b110a9f1c42eadc5404cdfa89d67ccffc4c6af24091967d43c068ce9e0c1b863cfc4eb5b4f12373a73756a9474f8294e8a44aabc28d8


To test:
->
getblock(getbestblockhash(), 1)[tx][22222222222222222222222222222]Before:
<-
868693731dea69a197c13c2cfaa41c9f78fcdeb8ab8e9f8cdf2c9025147ee7d1(hash of the coinbase tx)After:
<-
Error: Invalid result query