This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/295] New: inet_pton4() should disallow leading zeros (ambiguity with legacy octal)


This is for [glibc-2.3.3-200407231111],
file resolv/inet_pton.c,
function inet_pton4().

This is _not_ the usual complaint regarding the behavior of
inet_pton(AF_INET, foo, bar) vs inet_addr(foo).

The string "010.000.000.035" will be interpreted as the
IPv4 address 8.0.0.29 by inet_addr() and as the IPv4
address 10.0.0.35 by inet_pton().  This is bad.  If
inet_pton() doesn't want an input_format/interpretation
pair accepted by inet_addr(), it should just reject that
input_format with an error like it does for hexadecimal for
instance.

Unfortunately, the Internet RFCs are not strict on the
subject.  It can be argued that returning an error does
not contradict the RFCs, however, but rather follows
their spirit.

RFC 2373 "IP Version 6 Addressing Architecture" states in
"APPENDIX B: ABNF Description of Text Representations" that

      IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT

and RFC 3493 "Basic Socket Interface Extensions for IPv6"
states in "6.3 Address Conversion Functions" that

   If the af argument of inet_pton() is AF_INET, the src string shall be
   in the standard IPv4 dotted-decimal form:

      ddd.ddd.ddd.ddd

   where "ddd" is a one to three digit decimal number between 0 and 255.
   The inet_pton() function does not accept other formats (such as the
   octal numbers, hexadecimal numbers, and fewer than four numbers that
   inet_addr() accepts).

A proposed patch follows.  I wrote it and I am putting it in the public
domain.

-- 
           Summary: inet_pton4() should disallow leading zeros (ambiguity
                    with legacy octal)
           Product: glibc
           Version: 2.3.3
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: a dot guru at sympatico dot ca
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: n/a
  GCC host triplet: n/a
GCC target triplet: n/a


http://sources.redhat.com/bugzilla/show_bug.cgi?id=295

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]