Issue 7530 - gethostbyname_r fails if initial buffer size is too small
Summary: gethostbyname_r fails if initial buffer size is too small
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.33
Hardware: All All
: --- normal
Target Milestone: 2.5.0
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-26 18:09 UTC by ujvari@microsec.hu
Modified: 2020-10-14 21:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ujvari@microsec.hu 2013-02-26 18:09:12 UTC
Full_Name: Aron Ujvari
Version: 2.4.33
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (213.163.11.62)


OpenLDAP 2.4.33 (and before) does not handle properly when in function
ldap_pvt_gethostbyname_a the 6-args version of gethostname_r returns ERANGE(34)
error code because of too small buffer size.

Although there is a loop in the function to increment the buffer size, but there
is no check for ERANGE(34) result in the "r" variable, so no use of the loop.

Relevant code is in libraries/libldap/util-int.c, lines 336-368.

The gethostbyname man page clearly states at GNU Extensions section that
gethostbyname_r can return non-zero value on failure, and return ERANGE if "buf"
is too small, and the call should be retried with a larger buffer in this case.
Comment 1 Quanah Gibson-Mount 2017-04-03 17:33:20 UTC
moved from Incoming to Software Bugs
Comment 2 Quanah Gibson-Mount 2020-05-26 19:58:43 UTC
Commits: 
  • fb1933f5 
by Quanah Gibson-Mount at 2020-05-26T19:18:02+00:00 
Issue#7530 - Test for ERANGE when using 6 form gethostbyname_r
Comment 3 Quanah Gibson-Mount 2020-05-26 19:59:45 UTC
(In reply to ujvari@microsec.hu from comment #0)
> Full_Name: Aron Ujvari


köszönöm
Comment 4 ujvari@microsec.hu 2020-05-27 01:08:25 UTC
Én köszönöm a javítást.

It's me who thank you for fixing the problem.