Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fa0411b

Browse files
authored
Unrolled build for rust-lang#123798
Rollup merge of rust-lang#123798 - tniessen:patch-1, r=workingjubilee Avoid invalid socket address in length calculation This has no effect on the lengths of these constants, but since the IP address portion of the socket addresses was intentionally chosen to be the largest valid value, it seems appropriate to also use the largest valid value for the other components (as opposed to invalid values exceeding the possible ranges).
2 parents 616a8f8 + e1972c0 commit fa0411b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/net/socket_addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ impl fmt::Display for SocketAddrV4 {
591591
if f.precision().is_none() && f.width().is_none() {
592592
write!(f, "{}:{}", self.ip(), self.port())
593593
} else {
594-
const LONGEST_IPV4_SOCKET_ADDR: &str = "255.255.255.255:65536";
594+
const LONGEST_IPV4_SOCKET_ADDR: &str = "255.255.255.255:65535";
595595

596596
let mut buf = DisplayBuffer::<{ LONGEST_IPV4_SOCKET_ADDR.len() }>::new();
597597
// Buffer is long enough for the longest possible IPv4 socket address, so this should never fail.
@@ -621,7 +621,7 @@ impl fmt::Display for SocketAddrV6 {
621621
}
622622
} else {
623623
const LONGEST_IPV6_SOCKET_ADDR: &str =
624-
"[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%4294967296]:65536";
624+
"[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%4294967295]:65535";
625625

626626
let mut buf = DisplayBuffer::<{ LONGEST_IPV6_SOCKET_ADDR.len() }>::new();
627627
match self.scope_id() {

0 commit comments

Comments
 (0)