aboutsummaryrefslogtreecommitdiff
path: root/hesiod
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-05 23:32:24 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-05 23:32:24 +0000
commit87bb6b6c6bb6d5ff5e5b2a719fa32c77e9898459 (patch)
tree62536f4dd4680dc660ad8293e9a47ed7249ce4d3 /hesiod
parenta79d752f3da1085b4f00ef1a817d8beadcc3014a (diff)
downloadglibc-87bb6b6c6bb6d5ff5e5b2a719fa32c77e9898459.tar
glibc-87bb6b6c6bb6d5ff5e5b2a719fa32c77e9898459.tar.gz
glibc-87bb6b6c6bb6d5ff5e5b2a719fa32c77e9898459.tar.bz2
glibc-87bb6b6c6bb6d5ff5e5b2a719fa32c77e9898459.zip
Update.
2004-08-04 Jakub Jelinek <jakub@redhat.com> * hesiod/hesiod.c (__hesiod_res_get): Use calloc instead of malloc + memset. (__hesiod_res_set): Free nsaddrs. * include/resolv.h (__res_maybe_init): Add prototype. * resolv/resolv.h (struct __res_state): Add _u._ext.initstamp field. * resolv/Versions (libc): Add __res_maybe_init@@GLIBC_PRIVATE. * resolv/res_libc.c (__res_initstamp, lock): New variables. (res_init): Increase __res_initstamp. (__res_maybe_init): New function. * resolv/res_init.c (__res_vinit): Initialize _u._ext.initstamp. * hesiod/hesiod.c (__hesiod_res_get): Use __res_maybe_init instead of RES_INIT check and {res_ninit,__res_ninit,res_init} call. * sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise. * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r, _nss_dns_gethostbyaddr_r): Likewise. * resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r, _nss_dns_getnetbyaddr_r): Likewise. * resolv/gethnamaddr.c (gethostbyname, gethostbyname2, gethostbyaddr): Likewise. * resolv/res_data.c (fp_nquery, res_mkquery, res_mkupdate, res_isourserver, res_sendsigned, res_update, res_search, res_querydomain): Likewise. * nss/getXXbyYY_r.c (INTERNAL (REENTRANT_NAME)): Likewise. * nss/digits_dots.c (__nss_hostname_digits_dots): Likewise. * nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r): Likewise. * sysdeps/posix/getaddrinfo.c (gaih_inet): Set ai_family for V4-mapped IPv6 addresses and req->ai_family==AF_INET. Reported by A. Guru <a.guru@sympatico.ca>. * po/pl.po: Likewise. characters than necessary.
Diffstat (limited to 'hesiod')
-rw-r--r--hesiod/hesiod.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hesiod/hesiod.c b/hesiod/hesiod.c
index 630c71f96f..7fffb310f1 100644
--- a/hesiod/hesiod.c
+++ b/hesiod/hesiod.c
@@ -448,10 +448,9 @@ __hesiod_res_get(void *context) {
if (!ctx->res) {
struct __res_state *res;
- res = (struct __res_state *)malloc(sizeof *res);
+ res = (struct __res_state *)calloc(1, sizeof *res);
if (res == NULL)
return (NULL);
- memset(res, 0, sizeof *res);
__hesiod_res_set(ctx, res, free);
}
@@ -465,6 +464,12 @@ __hesiod_res_set(void *context, struct __res_state *res,
if (ctx->res && ctx->free_res) {
res_nclose(ctx->res);
+ if ((ctx->res->options & RES_INIT) && ctx->res->nscount > 0) {
+ for (int ns = 0; ns < MAXNS; ns++) {
+ free (ctx->res->_u._ext.nsaddrs[ns]);
+ ctx->res->_u._ext.nsaddrs[ns] = NULL;
+ }
+ }
(*ctx->free_res)(ctx->res);
}
@@ -478,8 +483,7 @@ init(struct hesiod_p *ctx) {
if (!ctx->res && !__hesiod_res_get(ctx))
return (-1);
- if (((ctx->res->options & RES_INIT) == 0) &&
- (res_ninit(ctx->res) == -1))
+ if (__res_maybe_init (ctx->res, 0) == -1)
return (-1);
return (0);