This is the mail archive of the glibc-bugs@sourceware.org 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 network/15014] New: gethostbyname_r() returns EINVAL (22) instead of ERANGE (34)


http://sourceware.org/bugzilla/show_bug.cgi?id=15014

             Bug #: 15014
           Summary: gethostbyname_r() returns EINVAL (22) instead of
                    ERANGE (34)
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
        AssignedTo: unassigned@sourceware.org
        ReportedBy: peter.klotz99@gmail.com
    Classification: Unclassified


Created attachment 6817
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6817
Source that demonstrates the problem

Under certain circumstances gethostbyname_r() returns EINVAL (22) instead of
ERANGE (34).

The attached source demonstrates the problem.

[user@host devel]$ g++ -W -Wall -DDNS_BUFFER_SIZE=37 dnslookup.cpp -o dnslookup
[user@host devel]$ ./dnslookup brain
error: 22 (Unknown resolver error)

[user@host devel]$ g++ -W -Wall -DDNS_BUFFER_SIZE=38 dnslookup.cpp -o dnslookup
[user@host devel]$ ./dnslookup brain

My /etc/hosts file contains this line to resolve host "brain":

10.18.1.19      brain

Using a 37 byte buffer gethostbyname_r() returns EINVAL. With a 38 byte buffer
gethostbyname_r() return ERANGE once, the buffer is doubled and the lookup
succeeds.

I can reproduce this behavior in RHEL5 (glibc 2.5), RHEL6 (glibc 2.12) and Arch
Linux (glibc 2.17) on x86_64.

Is there a minimum size for the buffer to start with? I found nothing in the
manpage.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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