Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#4515 closed defect (fixed)

tor_inet_pton(...) ipv6 addr. parsing inconsistencies

Reported by: 4ZM Owned by:
Priority: Medium Milestone:
Component: Core Tor/Tor Version:
Severity: Keywords: tor-client
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Currently:

  • "0x10::" is a valid addr according to tor_inet_pton but not according to inet_pton.
  • ":" is a seg fault waiting to happen. (src[1] <- out of bound)
  • "000010::" is an invalid addr according to tor_inet_pton but not according to inet_pton.

I suggest changing tor_inet_pton to make it consistent with inet_pton (as the doc states it should be).

I'll update the ticket with a patch in a moment.

Child Tickets

Change History (7)

comment:1 Changed 8 years ago by nickm

I'm okay with the first two changes, but "000010::" is not a valid IPv6 address. (Some platform implementations of inet_pton accept it, but I do not believe that the standard requires that they should.)

comment:2 Changed 8 years ago by 4ZM

Ok, so leading zeros should be invalid (ret 0)?

comment:3 Changed 8 years ago by nickm

No, some leading zeros are okay. 0010:: is a valid address; 0000010:: isn't. We should limit each piece to no more than 4 hexadecimal digits.

comment:4 Changed 8 years ago by 4ZM

Status: newneeds_review

Right.

Just found another minor bug in the current impl.

It allows more than 4 digits as the last position (next ptr == '\0' in this case).

A patch with all the above changes is available here:

https://github.com/4ZM/Tor.git
branch: topic/test/4515_tor_inet_pton

comment:5 Changed 8 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Added a changes file and merged to master; thanks!

comment:6 Changed 7 years ago by nickm

Keywords: tor-client added

comment:7 Changed 7 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.