common: json_to_s64 accept only valid JSON numbers - #9421
Conversation
Andezion
left a comment
There was a problem hiding this comment.
run-utils-str_to_s64.c has no direct test like assert(!str_to_s64("+123", 3, &val)) or assert(!str_to_s64("0x1A", 4, &val)). it only tests --123 and +-123 (mixed/double signs), which is a different case, maybe worth adding something like +123 and a hex string
|
If I'm following correctly, the old A few places I'd appreciate more context on:
|
bool str_to_s64 parses a decimal s64 from exactly buflen bytes; false on bad chars, overflow, leading +, hex like '0x...' . Similar behavior of json_to_u64 and str_to_u64. Tests added.
… duplicate includes. Changelog-Changed: routes json_to_s64() through the new str_to_s64(), which accepts strict decimal only. Leading zeros parse as decimal. Before was parsing as base-0 octal. Number with Hex (0x...) or plus signs are rejected.
fc1047e to
19b288c
Compare
Yes, it's considering acceptable also a minus signal and leading zeros are discarded.
yes, just that,
yes, the specification says: "A number is a sequence of decimal digits with no superfluous leading zero.". Looking at
Yes, that is possible. The same could happen to
It is out of scope at the moment.
Yes, it is missing, i will fix that. |
bool str_to_s64 parses a decimal s64 from exactly buflen bytes; false on bad chars, overflow, leading +, hex like '0x...' . Similar behavior of json_to_u64 and str_to_u64. Tests added. Partially fixes #9377
Important
26.09 FREEZE August 5th: Non-bugfix PRs not ready by this date will wait for 26.12.
RC1 is scheduled on August 17th
The final release is scheduled for September 7th.
Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:
tools/lightning-downgrade