Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
c91cafcf
Commit
c91cafcf
authored
Jul 16, 2020
by
Howard Chu
Committed by
Quanah Gibson-Mount
Jul 16, 2020
Browse files
ITS#9287 use getaddrinfo for ldap_pvt_get_fqdn
If getaddrinfo is available, should use it here
parent
50fdb180
Changes
1
Hide whitespace changes
Inline
Side-by-side
libraries/libldap/util-int.c
View file @
c91cafcf
...
...
@@ -834,10 +834,15 @@ static char *safe_realloc( char **buf, int len )
char
*
ldap_pvt_get_fqdn
(
char
*
name
)
{
char
*
fqdn
,
*
ha_buf
;
char
hostbuf
[
MAXHOSTNAMELEN
+
1
];
#ifdef HAVE_GETADDRINFO
struct
addrinfo
hints
,
*
res
;
#else
char
*
ha_buf
;
struct
hostent
*
hp
,
he_buf
;
int
rc
,
local_h_errno
;
int
local_h_errno
;
#endif
int
rc
;
char
*
fqdn
,
hostbuf
[
MAXHOSTNAMELEN
+
1
];
if
(
name
==
NULL
)
{
if
(
gethostname
(
hostbuf
,
MAXHOSTNAMELEN
)
==
0
)
{
...
...
@@ -848,6 +853,22 @@ char * ldap_pvt_get_fqdn( char *name )
}
}
#ifdef HAVE_GETADDRINFO
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_flags
=
AI_CANONNAME
;
LDAP_MUTEX_LOCK
(
&
ldap_int_resolv_mutex
);
rc
=
getaddrinfo
(
name
,
NULL
,
&
hints
,
&
res
);
LDAP_MUTEX_UNLOCK
(
&
ldap_int_resolv_mutex
);
if
(
rc
==
0
&&
res
->
ai_canonname
)
{
fqdn
=
LDAP_STRDUP
(
res
->
ai_canonname
);
}
else
{
fqdn
=
LDAP_STRDUP
(
name
);
}
if
(
rc
==
0
)
freeaddrinfo
(
res
);
#else
rc
=
ldap_pvt_gethostbyname_a
(
name
,
&
he_buf
,
&
ha_buf
,
&
hp
,
&
local_h_errno
);
...
...
@@ -858,6 +879,7 @@ char * ldap_pvt_get_fqdn( char *name )
}
LDAP_FREE
(
ha_buf
);
#endif
return
fqdn
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment