mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 18:22:57 +02:00
Merge bitcoin/bitcoin#30444: rest: Reject negative outpoint index early in getutxos parsing
fac932bf93refactor: Use util::Split to avoid a harmless unsigned-integer-overflow (MarcoFalke)fab54db9f1rest: Reject negative outpoint index in getutxos parsing (MarcoFalke) Pull request description: In `rest_getutxos` outpoint indexes such as `+N` or `-N` are accepted. This should be harmless, because any index out of range should be treated as a non-existent utxo. However, a negative index can't exist ever, so it seems better to reject all signs, whether `+` or `-`. ACKs for top commit: achow101: ACKfac932bf93hodlinator: ut-ACKfac932bf93tdb3: re ACKfac932bf93danielabrozzoni: ACKfac932bf93brunoerg: reACKfac932bf93Tree-SHA512: 8f1a75248cb61e1c4beceded6ed170db83b07f30fbcf93a26acfffc00ec4546572366eff87907a7e1423d7d3a2a9e57a0a7a9bacb787c86463f842d7161c16bc
This commit is contained in:
@@ -201,10 +201,13 @@ class RESTTest (BitcoinTestFramework):
|
||||
json_obj = self.test_rest_request(f"/getutxos/checkmempool/{spending[0]}-{spending[1]}")
|
||||
assert_equal(len(json_obj['utxos']), 1)
|
||||
|
||||
# Do some invalid requests
|
||||
self.log.info("Check some invalid requests")
|
||||
self.test_rest_request("/getutxos", http_method='POST', req_type=ReqType.JSON, body='{"checkmempool', status=400, ret_type=RetType.OBJ)
|
||||
self.test_rest_request("/getutxos", http_method='POST', req_type=ReqType.BIN, body='{"checkmempool', status=400, ret_type=RetType.OBJ)
|
||||
self.test_rest_request("/getutxos/checkmempool", http_method='POST', req_type=ReqType.JSON, status=400, ret_type=RetType.OBJ)
|
||||
self.test_rest_request(f"/getutxos/{spending[0]}_+1", ret_type=RetType.OBJ, status=400)
|
||||
self.test_rest_request(f"/getutxos/{spending[0]}-+1", ret_type=RetType.OBJ, status=400)
|
||||
self.test_rest_request(f"/getutxos/{spending[0]}--1", ret_type=RetType.OBJ, status=400)
|
||||
|
||||
# Test limits
|
||||
long_uri = '/'.join([f"{txid}-{n_}" for n_ in range(20)])
|
||||
|
||||
Reference in New Issue
Block a user