Commit Graph

16 Commits

Author SHA1 Message Date
marmeladema
8bb4b5f44c Support parsing IP addresses from a byte string 2022-08-26 14:16:53 +02:00
Mara Bos
4f212f08cf Use Rust 2021 prelude in std itself. 2022-05-09 11:12:32 +02:00
Chris Morgan
0255398ff7 Improve AddrParseError description
The existing description was incorrect for socket addresses, and
misleading: users would see “invalid IP address syntax” and suppose they
were supposed to provide an IP address rather than a socket address.

I contemplated making it two variants (IP, socket), but realised we can
do still better for the IPv4 and IPv6 types, so here it is as six.

I contemplated more precise error descriptions (e.g. “invalid IPv6
socket address syntax: expected a decimal scope ID after %”), but that’s
a more invasive change, and probably not worthwhile anyway.
2022-04-19 13:02:20 +10:00
Smittyvb
403d269f20 Specify maximum IP address length
Co-authored-by: Cheng XU <3105373+xu-cheng@users.noreply.github.com>
2021-08-10 16:43:17 -04:00
Smitty
a331e5fd2c Simplify leading zero checks 2021-07-11 11:33:39 -04:00
Smitty
b9b97bbb9d Reject too-long IPs quicker
Now that there can't be a bunch of leading zeros, parsing can be
optimized a bit.
2021-07-09 12:54:02 -04:00
Smitty
734bfdeaf2 Disallow octal zeros in IPv4 addresses 2021-07-08 14:13:42 -04:00
Cheng XU
974192cd98 Disallow octal format in Ipv4 string
In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.

This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.

Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.

Fixes #83648.

[IETF RFC 6943]: https://tools.ietf.org/html/rfc6943#section-3.1.1
2021-03-30 10:24:23 +08:00
pierwill
b86c0d85e5 (std::net::parser): Fix capitalization of IP versions
Also add some missing punctuation in doc and code comments.
2021-03-05 22:27:38 -08:00
Tamir Duberstein
49ade22bd9 Parse SocketAddrV6::scope_id 2020-10-06 22:13:15 +00:00
Tamir Duberstein
a093957f43 Avoid unused return 2020-10-06 22:12:16 +00:00
Tamir Duberstein
f78a7ade61 Inline "eof" methods 2020-10-04 17:07:30 +00:00
Tamir Duberstein
9601724b11 Avoid unchecked casts in net parser 2020-10-04 16:57:54 +00:00
Lzu Tao
a4e926daee std: move "mod tests/benches" to separate files
Also doing fmt inplace as requested.
2020-08-31 02:56:59 +00:00
Alexis Bourget
15cad1c465 Move to intra doc links in std::net 2020-08-15 19:17:19 +02:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00