You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bitcoin/short_channel_id: short_channel_id_from_str accepts trailing garbage, negative numbers, and whitespace #9700
This implementation allows several invalid string formats to succeed:
Trailing garbage / unparsed characters: sscanf does not check if the entire buffer length (strlen) is consumed. Strings such as "1x2x3garbage", "1x2x3/0", "1x2x3x4", or "1x2x3 4" successfully return true with valid dst filled from the initial match.
Negative outnums: %hu accepts negative numbers (e.g. "-1"), parsing them as 65535 ((u16)-1). In mk_short_channel_id(), (outnum & 0xFFFF) != outnum evaluates to 65535 != 65535 which is false, so "1x2x-1" is accepted as valid channel output 65535.
Leading / internal whitespace and signs: sscanf skips whitespace before numeric conversions and parses leading + signs, allowing strings like " 1x2x3", "1x 2x3", or "+1x2x3".
short_channel_id_dir_from_str pollution: Because short_channel_id_dir_from_str delegates to short_channel_id_from_str(str, slash - str, ...), strings like "1x2x3garbage/0" are also parsed without error.
Per BOLT 7, a short channel ID is uniquely represented by three decimal components delimited by 'x': <blocknum>x<txnum>x<outnum>. short_channel_id_from_str() should strictly parse the entire provided string and reject trailing garbage, negative values, signs, and whitespace.
getinfo output
N/A (observed in bitcoin/short_channel_id.c across all CLN versions).
Activity
bitcoin/short_channel_id: validate strict decimal format in short_cha…