Skip to content

Commit a90b08f

Browse files
authored
Add validation for trailing single colon in IPv6 address parsing (#1232)
- Added check in `scn_cnt_define_in6addr_shorten_impl` to return `parse_code::invalid` when buffer ends with single colon - Prevents accepting malformed IPv6 addresses ending with ":" instead of "::" or valid hex digit - Split compound condition to validate buffer bounds before checking for double colon
1 parent 23636e9 commit a90b08f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/fast_io_core_impl/socket/addrscn.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,11 @@ scn_cnt_define_in6addr_shorten_impl(char_type const *begin, char_type const *end
515515

516516
// Here *it == ':'
517517
++it;
518-
if (it != end && *it == colon)
518+
if (it == end)
519+
{
520+
return {it, parse_code::invalid};
521+
}
522+
if (*it == colon)
519523
{
520524
// Encountered "::"
521525
if (colonp != nullptr) [[unlikely]]

0 commit comments

Comments
 (0)