public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/15014] New: gethostbyname_r() returns EINVAL (22) instead of ERANGE (34)
@ 2013-01-12 21:41 peter.klotz99 at gmail dot com
  2013-04-15 11:33 ` [Bug network/15014] " siddhesh at redhat dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: peter.klotz99 at gmail dot com @ 2013-01-12 21:41 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-30  9:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12 21:41 [Bug network/15014] New: gethostbyname_r() returns EINVAL (22) instead of ERANGE (34) peter.klotz99 at gmail dot com
2013-04-15 11:33 ` [Bug network/15014] " siddhesh at redhat dot com
2013-04-15 13:02 ` siddhesh at redhat dot com
2013-05-21 10:57 ` schwab@linux-m68k.org
2014-06-13 19:04 ` fweimer at redhat dot com
2015-01-27 15:07 ` [Bug network/15014] gethostbyname_r() returns EINVAL (22) instead of ERANGE (34) (CVE-2015-0235) fweimer at redhat dot com
2015-01-27 23:41 ` lauri.love at gmail dot com
2015-01-28  1:59 ` joseph at codesourcery dot com
2015-01-28 12:10 ` lauri.love at gmail dot com
2021-11-30  9:14 ` ma.ro.so01234567890 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).