* sysdeps/posix/getaddrinfo.c (gaih_inet): Don't use
	getcanonname_r function if AI_CANONNAME flag is not set in
	request.
This commit is contained in:
Ulrich Drepper 2004-08-19 21:39:39 +00:00
parent 8583671dd4
commit afd7b70333
3 changed files with 32 additions and 25 deletions

View File

@ -1,5 +1,9 @@
2004-08-19 Ulrich Drepper <drepper@redhat.com> 2004-08-19 Ulrich Drepper <drepper@redhat.com>
* sysdeps/posix/getaddrinfo.c (gaih_inet): Don't use
getcanonname_r function if AI_CANONNAME flag is not set in
request.
* nis/nss_compat/compat-initgroups.c (getgrent_next_nss): * nis/nss_compat/compat-initgroups.c (getgrent_next_nss):
Initialize mysize with limits only if latter is >= 0. Use mysize Initialize mysize with limits only if latter is >= 0. Use mysize
in malloc call. in malloc call.

View File

@ -243,9 +243,9 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
{ {
long int mystart = 0; long int mystart = 0;
long int mysize = limit <= 0 ? *size : limit; long int mysize = limit <= 0 ? *size : limit;
gid_t *mygroupsp = malloc (mysize * sizeof (gid_t)); gid_t *mygroups = malloc (mysize * sizeof (gid_t));
if (mygroupsp == NULL) if (mygroups == NULL)
return NSS_STATUS_TRYAGAIN; return NSS_STATUS_TRYAGAIN;
/* For every gid in the list we get from the NSS module, /* For every gid in the list we get from the NSS module,
@ -255,7 +255,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
getgrent_r through the whole group database. But for large getgrent_r through the whole group database. But for large
group databases this is faster, since the user can only be group databases this is faster, since the user can only be
in a limited number of groups. */ in a limited number of groups. */
if (nss_initgroups_dyn (user, group, &mystart, &mysize, &mygroupsp, if (nss_initgroups_dyn (user, group, &mystart, &mysize, &mygroups,
limit, errnop) == NSS_STATUS_SUCCESS) limit, errnop) == NSS_STATUS_SUCCESS)
{ {
/* A temporary buffer. We use the normal buffer, until we find /* A temporary buffer. We use the normal buffer, until we find
@ -267,7 +267,7 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
for (i = 0; i < mystart; i++) for (i = 0; i < mystart; i++)
{ {
while ((status = nss_getgrgid_r (mygroupsp[i], &grpbuf, tmpbuf, while ((status = nss_getgrgid_r (mygroups[i], &grpbuf, tmpbuf,
tmplen, tmplen,
errnop)) == NSS_STATUS_TRYAGAIN errnop)) == NSS_STATUS_TRYAGAIN
&& *errnop == ERANGE) && *errnop == ERANGE)
@ -285,12 +285,12 @@ getgrent_next_nss (ent_t *ent, char *buffer, size_t buflen, const char *user,
limit, &grpbuf); limit, &grpbuf);
} }
free (mygroupsp); free (mygroups);
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
} }
free (mygroupsp); free (mygroups);
} }
/* If we come here, the NSS module does not support initgroups_dyn /* If we come here, the NSS module does not support initgroups_dyn

View File

@ -644,27 +644,30 @@ gaih_inet (const char *name, const struct gaih_service *service,
if (inet6_status == NSS_STATUS_SUCCESS if (inet6_status == NSS_STATUS_SUCCESS
|| status == NSS_STATUS_SUCCESS) || status == NSS_STATUS_SUCCESS)
{ {
/* If we need the canonical name, get it from the same if ((req->ai_flags & AI_CANONNAME) != 0)
service as the result. */
nss_getcanonname_r cfct;
int herrno;
cfct = __nss_lookup_function (nip, "getcanonname_r");
if (cfct != NULL)
{ {
const size_t max_fqdn_len = 256; /* If we need the canonical name, get it
char *buf = alloca (max_fqdn_len); from the same service as the result. */
char *s; nss_getcanonname_r cfct;
int herrno;
if (DL_CALL_FCT (cfct, (h->h_name ?: name, buf, cfct = __nss_lookup_function (nip, "getcanonname_r");
max_fqdn_len, &s, &rc, if (cfct != NULL)
&herrno)) {
== NSS_STATUS_SUCCESS) const size_t max_fqdn_len = 256;
canon = s; char *buf = alloca (max_fqdn_len);
else char *s;
/* Set to name now to avoid using
gethostbyaddr. */ if (DL_CALL_FCT (cfct, (h->h_name ?: name, buf,
canon = name; max_fqdn_len, &s, &rc,
&herrno))
== NSS_STATUS_SUCCESS)
canon = s;
else
/* Set to name now to avoid using
gethostbyaddr. */
canon = name;
}
} }
break; break;