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/515] New: gethostbyname_r() returns incorrect error for certain sizes (or alignment)


Hi,

I am having this very weird problem: I am trying to resolve an hostname using
gethostbyname_r(). It seems that for certain buffer sizes, the resolver acts as
though resolving failed. As you'll see, for a correct buffer size
gethostbyname_r will resolve the name successfully. Here is sample output (I'll
attach the source of the program):

gmorin@linux:~> gcc -o foo foo.c -Wall -DBUFFER_SIZE=128 && ./foo
ret is 34, result is (nil), err is -1
error: Numerical result out of range.
gmorin@linux:~> gcc -o foo foo.c -Wall -DBUFFER_SIZE=256 && ./foo
ret is 0, result is (nil), err is 2
error: No such file or directory.
gmorin@linux:~> gcc -o foo foo.c -Wall -DBUFFER_SIZE=512 && ./foo
ret is 0, result is 0xbffff2f0, err is 1
Success resolving sundev1. Found aliases:  sndv1p sundev1fddi sdv1 sundev1d
gmorin@linux:~>

As you'll see, for a size of 256 we get ENOENT instead of ERANGE.

For this report, I tried to make a testcase which would allocate a buffer of
1024 bytes on the stack and just call gethostbyname_r() with a certain buf_size
but the bug did not appear in that case. The call using a size of 256 returned
ERANGE. So I wonder if it might be related to alignment or something weird.

Glibc is glibc-2.3.3-93 from SuSE. Kernel is 2.6.9.

HTH.

Guillaume.

-- 
           Summary: gethostbyname_r() returns incorrect error for certain
                    sizes (or alignment)
           Product: glibc
           Version: 2.3.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: gmorin1 at bloomberg dot net
                CC: glibc-bugs at sources dot redhat dot com


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

------- 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]