torproject / tor Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#27325: Rework NETINFO wire format handling to rely on trunnel (2) #445
#27325: Rework NETINFO wire format handling to rely on trunnel (2) #445
Conversation
Pull Request Test Coverage Report for Build 3324
|
| const NETINFO_ADDR_TYPE_IPV4 = 4; | ||
| const NETINFO_ADDR_TYPE_IPV6 = 6; | ||
|
|
||
| struct netinfo_addr { |
This breaks forward compatibility. It means that Tor will no longer handle any NETINFO cell that ever declares a future address type.
We need to support and ignore unrecognized address types, and let them have whatever type they need to.
src/core/or/channeltls.c
Outdated
| decode_address_from_payload(&addr, cp, (int)(end-cp)); | ||
| if (next == NULL) { | ||
|
|
||
| if (tor_addr_from_netinfo_addr(&addr, netinfo_addr) == -1) { | ||
| log_fn(LOG_PROTOCOL_WARN, LD_OR, | ||
| "Bad address in netinfo cell; closing connection."); | ||
| connection_or_close_for_error(chan->conn, 0); |
Hang on, does this mean that we previously rejected unrecognized address types? That's not good...
src/trunnel/netinfo.trunnel
Outdated
| u8 addr_type IN [NETINFO_ADDR_TYPE_IPV4, NETINFO_ADDR_TYPE_IPV6]; | ||
| u8 len IN [4, 16]; | ||
| u8 addr_type; | ||
| u8 len; | ||
| union addr[addr_type] { | ||
| NETINFO_ADDR_TYPE_IPV4: u32 ipv4; | ||
| NETINFO_ADDR_TYPE_IPV6: u8 ipv6[16]; | ||
| default: fail; |
This is still going to mean that if addr_type isn't recognized, parsing fails.
Try replacing the union line with union addr[addr_type] with length len {, and the default line with default: ignore -- I think that will do it.
Also, we should have unit tests that make sure that this case actually works.
Ignore the address value instead of failing with error condition in case unrecognized address type is found.
https://trac.torproject.org/projects/tor/ticket/27325
The text was updated successfully, but these errors were encountered: