mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
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.
This commit is contained in:
37
ChangeLog
37
ChangeLog
@ -1,13 +1,48 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2004-08-05 Ulrich Drepper <drepper@redhat.com>
|
2004-08-05 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* 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/sv.po: Update from translation team.
|
* po/sv.po: Update from translation team.
|
||||||
* po/sk.po: Likewise.
|
* po/sk.po: Likewise.
|
||||||
|
* po/pl.po: Likewise.
|
||||||
|
|
||||||
2004-08-04 Jakub Jelinek <jakub@redhat.com>
|
2004-08-04 Jakub Jelinek <jakub@redhat.com>
|
||||||
Ulrich Drepper <drepper@redhat.com>
|
Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Don't read more input
|
* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Don't read more input
|
||||||
character than necessary.
|
characters than necessary.
|
||||||
|
|
||||||
2004-08-05 Ulrich Drepper <drepper@redhat.com>
|
2004-08-05 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
@ -448,10 +448,9 @@ __hesiod_res_get(void *context) {
|
|||||||
|
|
||||||
if (!ctx->res) {
|
if (!ctx->res) {
|
||||||
struct __res_state *res;
|
struct __res_state *res;
|
||||||
res = (struct __res_state *)malloc(sizeof *res);
|
res = (struct __res_state *)calloc(1, sizeof *res);
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
memset(res, 0, sizeof *res);
|
|
||||||
__hesiod_res_set(ctx, res, free);
|
__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) {
|
if (ctx->res && ctx->free_res) {
|
||||||
res_nclose(ctx->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);
|
(*ctx->free_res)(ctx->res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,8 +483,7 @@ init(struct hesiod_p *ctx) {
|
|||||||
if (!ctx->res && !__hesiod_res_get(ctx))
|
if (!ctx->res && !__hesiod_res_get(ctx))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
if (((ctx->res->options & RES_INIT) == 0) &&
|
if (__res_maybe_init (ctx->res, 0) == -1)
|
||||||
(res_ninit(ctx->res) == -1))
|
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -31,6 +31,7 @@ extern struct __res_state _res;
|
|||||||
|
|
||||||
/* Now define the internal interfaces. */
|
/* Now define the internal interfaces. */
|
||||||
extern int __res_vinit (res_state, int);
|
extern int __res_vinit (res_state, int);
|
||||||
|
extern int __res_maybe_init (res_state, int);
|
||||||
extern void _sethtent (int);
|
extern void _sethtent (int);
|
||||||
extern void _endhtent (void);
|
extern void _endhtent (void);
|
||||||
extern struct hostent *_gethtent (void);
|
extern struct hostent *_gethtent (void);
|
||||||
@ -46,6 +47,7 @@ extern void res_send_setrhook (res_send_rhook __hook);
|
|||||||
extern int res_ourserver_p (const res_state __statp,
|
extern int res_ourserver_p (const res_state __statp,
|
||||||
const struct sockaddr_in6 *__inp);
|
const struct sockaddr_in6 *__inp);
|
||||||
libc_hidden_proto (__res_ninit)
|
libc_hidden_proto (__res_ninit)
|
||||||
|
libc_hidden_proto (__res_maybe_init)
|
||||||
libc_hidden_proto (__res_nclose)
|
libc_hidden_proto (__res_nclose)
|
||||||
libc_hidden_proto (__res_randomid)
|
libc_hidden_proto (__res_randomid)
|
||||||
libc_hidden_proto (__res_state)
|
libc_hidden_proto (__res_state)
|
||||||
|
@ -43,7 +43,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
|
|||||||
|
|
||||||
/* We have to test for the use of IPv6 which can only be done by
|
/* We have to test for the use of IPv6 which can only be done by
|
||||||
examining `_res'. */
|
examining `_res'. */
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
{
|
{
|
||||||
if (h_errnop)
|
if (h_errnop)
|
||||||
*h_errnop = NETDB_INTERNAL;
|
*h_errnop = NETDB_INTERNAL;
|
||||||
|
@ -182,7 +182,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
|
|||||||
#ifdef NEED__RES
|
#ifdef NEED__RES
|
||||||
/* The resolver code will really be used so we have to
|
/* The resolver code will really be used so we have to
|
||||||
initialize it. */
|
initialize it. */
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
{
|
{
|
||||||
*h_errnop = NETDB_INTERNAL;
|
*h_errnop = NETDB_INTERNAL;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000,02 Free Software Foundation, Inc.
|
/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -60,8 +60,7 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
|
|||||||
} fct;
|
} fct;
|
||||||
int no_more;
|
int no_more;
|
||||||
|
|
||||||
if (res && (_res.options & RES_INIT) == 0
|
if (res && __res_maybe_init (&_res, 0) == -1)
|
||||||
&& __res_ninit (&_res) == -1)
|
|
||||||
{
|
{
|
||||||
__set_h_errno (NETDB_INTERNAL);
|
__set_h_errno (NETDB_INTERNAL);
|
||||||
return;
|
return;
|
||||||
@ -104,8 +103,7 @@ __nss_endent (const char *func_name, db_lookup_function lookup_fct,
|
|||||||
} fct;
|
} fct;
|
||||||
int no_more;
|
int no_more;
|
||||||
|
|
||||||
if (res && (_res.options & RES_INIT) == 0
|
if (res && __res_maybe_init (&_res, 0) == -1)
|
||||||
&& __res_ninit (&_res) == -1)
|
|
||||||
{
|
{
|
||||||
__set_h_errno (NETDB_INTERNAL);
|
__set_h_errno (NETDB_INTERNAL);
|
||||||
return;
|
return;
|
||||||
@ -145,8 +143,7 @@ __nss_getent_r (const char *getent_func_name,
|
|||||||
int no_more;
|
int no_more;
|
||||||
enum nss_status status;
|
enum nss_status status;
|
||||||
|
|
||||||
if (res && (_res.options & RES_INIT) == 0
|
if (res && __res_maybe_init (&_res, 0) == -1)
|
||||||
&& __res_ninit (&_res) == -1)
|
|
||||||
{
|
{
|
||||||
*h_errnop = NETDB_INTERNAL;
|
*h_errnop = NETDB_INTERNAL;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
@ -38,6 +38,8 @@ libc {
|
|||||||
# This version is for the TLS symbol, GLIBC_2.0 is the old object symbol.
|
# This version is for the TLS symbol, GLIBC_2.0 is the old object symbol.
|
||||||
h_errno; __resp;
|
h_errno; __resp;
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
__res_maybe_init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,10 +493,10 @@ gethostbyname(name)
|
|||||||
{
|
{
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1) {
|
if (__res_maybe_init (&_res, 0) == -1) {
|
||||||
__set_h_errno (NETDB_INTERNAL);
|
__set_h_errno (NETDB_INTERNAL);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (_res.options & RES_USE_INET6) {
|
if (_res.options & RES_USE_INET6) {
|
||||||
hp = gethostbyname2(name, AF_INET6);
|
hp = gethostbyname2(name, AF_INET6);
|
||||||
if (hp)
|
if (hp)
|
||||||
@ -522,7 +522,7 @@ gethostbyname2(name, af)
|
|||||||
struct hostent *ret;
|
struct hostent *ret;
|
||||||
extern struct hostent *_gethtbyname2();
|
extern struct hostent *_gethtbyname2();
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1) {
|
if (__res_maybe_init (&_res, 0) == -1) {
|
||||||
__set_h_errno (NETDB_INTERNAL);
|
__set_h_errno (NETDB_INTERNAL);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -665,7 +665,7 @@ gethostbyaddr(addr, len, af)
|
|||||||
#endif /*SUNSECURITY*/
|
#endif /*SUNSECURITY*/
|
||||||
extern struct hostent *_gethtbyaddr();
|
extern struct hostent *_gethtbyaddr();
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1) {
|
if (__res_maybe_init (&_res, 0) == -1) {
|
||||||
__set_h_errno (NETDB_INTERNAL);
|
__set_h_errno (NETDB_INTERNAL);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ _nss_dns_gethostbyname2_r (const char *name, int af, struct hostent *result,
|
|||||||
int olderr = errno;
|
int olderr = errno;
|
||||||
enum nss_status status;
|
enum nss_status status;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
switch (af) {
|
switch (af) {
|
||||||
@ -263,7 +263,7 @@ _nss_dns_gethostbyaddr_r (const void *addr, socklen_t len, int af,
|
|||||||
int n, status;
|
int n, status;
|
||||||
int olderr = errno;
|
int olderr = errno;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
if (af == AF_INET6 && len == IN6ADDRSZ
|
if (af == AF_INET6 && len == IN6ADDRSZ
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004
|
||||||
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Extended from original form by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
Extended from original form by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ _nss_dns_getnetbyname_r (const char *name, struct netent *result,
|
|||||||
char *qbuf;
|
char *qbuf;
|
||||||
enum nss_status status;
|
enum nss_status status;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
qbuf = strdupa (name);
|
qbuf = strdupa (name);
|
||||||
@ -171,7 +172,7 @@ _nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result,
|
|||||||
if (type != AF_INET)
|
if (type != AF_INET)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit (&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
net2 = (u_int32_t) net;
|
net2 = (u_int32_t) net;
|
||||||
|
@ -141,7 +141,7 @@ fp_query(const u_char *msg, FILE *file) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
fp_nquery(const u_char *msg, int len, FILE *file) {
|
fp_nquery(const u_char *msg, int len, FILE *file) {
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
res_pquery(&_res, msg, len, file);
|
res_pquery(&_res, msg, len, file);
|
||||||
@ -157,7 +157,7 @@ res_mkquery(int op, /* opcode of query */
|
|||||||
u_char *buf, /* buffer to put query */
|
u_char *buf, /* buffer to put query */
|
||||||
int buflen) /* size of buffer */
|
int buflen) /* size of buffer */
|
||||||
{
|
{
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ res_mkquery(int op, /* opcode of query */
|
|||||||
#ifdef BIND_UPDATE
|
#ifdef BIND_UPDATE
|
||||||
int
|
int
|
||||||
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
|
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ res_query(const char *name, /* domain name */
|
|||||||
u_char *answer, /* buffer to put answer */
|
u_char *answer, /* buffer to put answer */
|
||||||
int anslen) /* size of answer buffer */
|
int anslen) /* size of answer buffer */
|
||||||
{
|
{
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ res_isourserver(const struct sockaddr_in *inp) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
|
res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
/* errno should have been set by res_init() in this case. */
|
/* errno should have been set by res_init() in this case. */
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ int
|
|||||||
res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key,
|
res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key,
|
||||||
u_char *ans, int anssiz)
|
u_char *ans, int anssiz)
|
||||||
{
|
{
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
/* errno should have been set by res_init() in this case. */
|
/* errno should have been set by res_init() in this case. */
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ res_close(void) {
|
|||||||
#ifdef BIND_UPDATE
|
#ifdef BIND_UPDATE
|
||||||
int
|
int
|
||||||
res_update(ns_updrec *rrecp_in) {
|
res_update(ns_updrec *rrecp_in) {
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ res_search(const char *name, /* domain name */
|
|||||||
u_char *answer, /* buffer to put answer */
|
u_char *answer, /* buffer to put answer */
|
||||||
int anslen) /* size of answer */
|
int anslen) /* size of answer */
|
||||||
{
|
{
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ res_querydomain(const char *name,
|
|||||||
u_char *answer, /* buffer to put answer */
|
u_char *answer, /* buffer to put answer */
|
||||||
int anslen) /* size of answer */
|
int anslen) /* size of answer */
|
||||||
{
|
{
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
if (__res_maybe_init (&_res, 1) == -1) {
|
||||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,10 @@ __res_vinit(res_state statp, int preinit) {
|
|||||||
#ifndef RFC1535
|
#ifndef RFC1535
|
||||||
int dots;
|
int dots;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _LIBC
|
||||||
|
extern unsigned long long int __res_initstamp attribute_hidden;
|
||||||
|
statp->_u._ext.initstamp = __res_initstamp;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!preinit) {
|
if (!preinit) {
|
||||||
statp->retrans = RES_TIMEOUT;
|
statp->retrans = RES_TIMEOUT;
|
||||||
|
@ -15,16 +15,31 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/nameser.h>
|
#include <arpa/nameser.h>
|
||||||
#include <resolv.h>
|
#include <resolv.h>
|
||||||
|
#include <bits/libc-lock.h>
|
||||||
|
|
||||||
|
|
||||||
/* The following bit is copied from res_data.c (where it is #ifdef'ed
|
/* The following bit is copied from res_data.c (where it is #ifdef'ed
|
||||||
out) since res_init() should go into libc.so but the rest of that
|
out) since res_init() should go into libc.so but the rest of that
|
||||||
file should not. */
|
file should not. */
|
||||||
|
|
||||||
|
unsigned long long int __res_initstamp attribute_hidden;
|
||||||
|
/* We have atomic increment operations on 64-bit platforms. */
|
||||||
|
#if __WORDSIZE == 64
|
||||||
|
# define atomicinclock(lock) (void) 0
|
||||||
|
# define atomicincunlock(lock) (void) 0
|
||||||
|
# define atomicinc(var) atomic_increment (&(var))
|
||||||
|
#else
|
||||||
|
__libc_lock_define_initialized (static, lock);
|
||||||
|
# define atomicinclock(lock) __libc_lock_lock (lock)
|
||||||
|
# define atomicincunlock(lock) __libc_lock_unlock (lock)
|
||||||
|
# define atomicinc(var) ++var
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
res_init(void) {
|
res_init(void) {
|
||||||
extern int __res_vinit(res_state, int);
|
extern int __res_vinit(res_state, int);
|
||||||
@ -70,8 +85,45 @@ res_init(void) {
|
|||||||
if (!_res.id)
|
if (!_res.id)
|
||||||
_res.id = res_randomid();
|
_res.id = res_randomid();
|
||||||
|
|
||||||
|
atomicinclock (lock);
|
||||||
|
/* Request all threads to re-initialize their resolver states,
|
||||||
|
resolv.conf might have changed. */
|
||||||
|
atomicinc (__res_initstamp);
|
||||||
|
atomicincunlock (lock);
|
||||||
|
|
||||||
return (__res_vinit(&_res, 1));
|
return (__res_vinit(&_res, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize resp if RES_INIT is not yet set or if res_init in some other
|
||||||
|
thread requested re-initializing. */
|
||||||
|
int
|
||||||
|
__res_maybe_init (res_state resp, int preinit)
|
||||||
|
{
|
||||||
|
if (resp->options & RES_INIT) {
|
||||||
|
if (__res_initstamp != resp->_u._ext.initstamp) {
|
||||||
|
if (resp->nscount > 0) {
|
||||||
|
__res_nclose (resp);
|
||||||
|
for (int ns = 0; ns < MAXNS; ns++) {
|
||||||
|
free (resp->_u._ext.nsaddrs[ns]);
|
||||||
|
resp->_u._ext.nsaddrs[ns] = NULL;
|
||||||
|
}
|
||||||
|
return __res_vinit (resp, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if (preinit) {
|
||||||
|
if (!resp->retrans)
|
||||||
|
resp->retrans = RES_TIMEOUT;
|
||||||
|
if (!resp->retry)
|
||||||
|
resp->retry = 4;
|
||||||
|
resp->options = RES_DEFAULT;
|
||||||
|
if (!resp->id)
|
||||||
|
resp->id = res_randomid ();
|
||||||
|
return __res_vinit (resp, 1);
|
||||||
|
} else
|
||||||
|
return __res_ninit (resp);
|
||||||
|
}
|
||||||
|
libc_hidden_def (__res_maybe_init)
|
||||||
|
|
||||||
/* This needs to be after the use of _res in res_init, above. */
|
/* This needs to be after the use of _res in res_init, above. */
|
||||||
#undef _res
|
#undef _res
|
||||||
|
@ -134,6 +134,12 @@ struct __res_state {
|
|||||||
u_int16_t nscount6;
|
u_int16_t nscount6;
|
||||||
u_int16_t nsinit;
|
u_int16_t nsinit;
|
||||||
struct sockaddr_in6 *nsaddrs[MAXNS];
|
struct sockaddr_in6 *nsaddrs[MAXNS];
|
||||||
|
#ifdef _LIBC
|
||||||
|
unsigned long long int initstamp
|
||||||
|
__attribute__((packed));
|
||||||
|
#else
|
||||||
|
unsigned int _initstamp[2];
|
||||||
|
#endif
|
||||||
} _ext;
|
} _ext;
|
||||||
} _u;
|
} _u;
|
||||||
};
|
};
|
||||||
|
@ -604,8 +604,12 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|||||||
{
|
{
|
||||||
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
|
||||||
at->family = AF_INET6;
|
at->family = AF_INET6;
|
||||||
else if (IN6_IS_ADDR_V4MAPPED (at->addr))
|
else if (req->ai_family == AF_INET
|
||||||
*(uint32_t *) at->addr = ((uint32_t *) at->addr)[3];
|
&& IN6_IS_ADDR_V4MAPPED (at->addr))
|
||||||
|
{
|
||||||
|
*(uint32_t *) at->addr = ((uint32_t *) at->addr)[3];
|
||||||
|
at->family = AF_INET;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return -EAI_ADDRFAMILY;
|
return -EAI_ADDRFAMILY;
|
||||||
|
|
||||||
@ -662,7 +666,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|||||||
no_more = __nss_database_lookup ("hosts", NULL,
|
no_more = __nss_database_lookup ("hosts", NULL,
|
||||||
"dns [!UNAVAIL=return] files", &nip);
|
"dns [!UNAVAIL=return] files", &nip);
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1)
|
if (__res_maybe_init (&_res, 0) == -1)
|
||||||
no_more = 1;
|
no_more = 1;
|
||||||
old_res_options = _res.options;
|
old_res_options = _res.options;
|
||||||
_res.options &= ~RES_USE_INET6;
|
_res.options &= ~RES_USE_INET6;
|
||||||
|
Reference in New Issue
Block a user