diff options
author | MacroFake <falke.marco@gmail.com> | 2022-06-14 15:15:19 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-06-14 15:15:22 +0200 |
commit | a05876619a3307daefec0946de8e3cbbe5b0157f (patch) | |
tree | 4465eab0cfe69f73df379801bd0d7474cf6b820f /test | |
parent | 9e4fbebcc8e497016563e46de4c64fa094edab2d (diff) | |
parent | 42bbbba7c83d1e2baad18b4c6f05bad1358eb117 (diff) | |
download | bitcoin-a05876619a3307daefec0946de8e3cbbe5b0157f.tar.xz |
Merge bitcoin/bitcoin#25367: [contrib] message-capture-parser: fix out of bounds error for empty vectors
42bbbba7c83d1e2baad18b4c6f05bad1358eb117 message-capture-parser: fix out of bounds error for empty vectors (Sebastian Falbesoner)
Pull request description:
The script [message-capture-parser.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/message-capture/message-capture-parser.py) currently throws an "out of bounds" error if a message containing an empty integer vector element is tried to converted to JSON (e.g. by the BIP157 message `cfcheckpt` with empty `FilterHeaders` vector):
```
Traceback (most recent call last):
File "/home/honey/bitcoin/./contrib/message-capture/message-capture-parser.py", line 217, in <module>
main()
File "/home/honey/bitcoin/./contrib/message-capture/message-capture-parser.py", line 202, in main
process_file(str(capture), messages, "recv" in capture.stem, progress_bar)
File "/home/honey/bitcoin/./contrib/message-capture/message-capture-parser.py", line 162, in process_file
msg_dict["body"] = to_jsonable(msg)
File "/home/honey/bitcoin/./contrib/message-capture/message-capture-parser.py", line 85, in to_jsonable
elif slot in HASH_INT_VECTORS and isinstance(val[0], int):
IndexError: list index out of range
```
Fix this by using the `all(...)` predicate rather to access the first element `val[0]` (which in the error case doesn't exist).
ACKs for top commit:
laanwj:
Code review ACK 42bbbba7c83d1e2baad18b4c6f05bad1358eb117
Tree-SHA512: 139ec6b90304a69f26ec731e6f12b216fa10e554f777505b61adfa1e569f6861a4a849159dd1eae7a1aa0427e8598af226b6f0c4015020dcac8ab109fbc35dba
Diffstat (limited to 'test')
0 files changed, 0 insertions, 0 deletions