diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-10-09 09:42:48 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-10-09 09:42:48 +0000 |
commit | 6166815d696407069c33c1f0cad76fb1847e4bc7 (patch) | |
tree | d7aaf5fd8551eb6d69fb80863a4a415cfaa9c01a /resolv/gethnamaddr.c | |
parent | 4c2821faea94c4300fe283f13e4a667f1f73b90b (diff) | |
download | glibc-6166815d696407069c33c1f0cad76fb1847e4bc7.zip glibc-6166815d696407069c33c1f0cad76fb1847e4bc7.tar.gz glibc-6166815d696407069c33c1f0cad76fb1847e4bc7.tar.bz2 |
Update.
2002-10-09 Ulrich Drepper <drepper@redhat.com>
* Versions.def (libc): Add GLIBC_2.3.1.
(libpthread): Add GLIBC_2.3.1.
* include/signal.h: Add libc_hidden_proto for __sigwait, __sigwaitinfo,
and __sigtimedwait.
* signal/Versions: Add __sigtimedwait, __sigwait, and __sigwaitinfo.
* sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Add
libc_hidden_def.
* sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Likewise.
* sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise.
* include/sys/msg.h: Declare __libc_msgrcv and __libc_msgsnd.
* sysdeps/unix/sysv/linux/msgrcv.c (__msgrcv): Rename to __libc_msgrcv
and make old name an alias.
* sysdeps/unix/sysv/linux/msgsnd.c (__msgsnd): Rename to __libc_msgsnd
and make old name an alias.
* sysvipc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_msgrcv and
__libc_msgsnd.
* include/sys/uio.h: Declare __libc_readv and __libc_writev.
* misc/Versions (libc) [GLIBC_PRIVATE]: Add __libc_readv and
__libc_writev.
* sysdeps/generic/readv.c (__readv): Rename to __libc_readv and make
old name an alias.
* sysdeps/posix/readv.c: Likewise
* sysdeps/unix/sysv/aix/readv.c: Likewise.
* sysdeps/unix/sysv/linux/readv.c: Likewise.
* sysdeps/generic/writev.c (__writev): Rename to __libc_writev and make
old name an alias.
* sysdeps/posix/writev.c: Likewise
* sysdeps/unix/sysv/aix/writev.c: Likewise.
* sysdeps/unix/sysv/linux/writev.c: Likewise.
* include/sys/wait.h: Declare __waitid.
* posix/Versions (libc) [GLIBC_PRIVATE]: Add __waitid.
* sysdeps/generic/waitid.c (waitid): Rename to __waitid and make old
name an alias.
* sysdeps/posix/waitid.c: Likewise.
* sysdeps/unix/sysv/aix/waitid.c: Likewise.
* sysdeps/unix/sysv/linux/syscalls.list: Add creat syscall.
2002-10-07 Jakub Jelinek <jakub@redhat.com>
* include/alloca.h (__libc_use_alloca, __libc_alloca_cutoff): New
prototypes.
(__MAX_ALLOCA_CUTOFF): Define.
Include allocalim.h.
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r,
_nss_dns_gethostbyaddr_r): Use alloca or malloc to allocate
host_buffer depending on __libc_use_alloca.
* resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r,
_nss_dns_getnetbyaddr_r): Use alloca or malloc to allocate
net_buffer depending on __libc_use_alloca.
* resolv/res_query.c (res_nquery): Use alloca or malloc to allocate
buf depending on __libc_use_alloca.
* resolv/gethnamaddr.c (gethostbyname2, gethostbyaddr): Likewise.
* stdio-common/vfprintf.c (vfprintf): Use __libc_use_alloca
instead of hardcoded constants.
Pass proper size argument to alloca and compute end for wide char
version.
* stdio-common/printf_fp.c (__printf_fp): Use __libc_use_alloca
instead of hardcoded constants.
* string/strcoll.c (strcoll): Likewise.
* string/strxfrm.c (strxfrm): Likewise.
* sysdeps/posix/readv.c (__readv): Likewise.
* sysdeps/posix/writev.c (__writev): Likewise.
* sysdeps/generic/allocalim.h: New file.
Diffstat (limited to 'resolv/gethnamaddr.c')
-rw-r--r-- | resolv/gethnamaddr.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c index 1ab102b..797af94 100644 --- a/resolv/gethnamaddr.c +++ b/resolv/gethnamaddr.c @@ -510,10 +510,11 @@ gethostbyname2(name, af) const char *name; int af; { - querybuf buf; + querybuf *buf; register const char *cp; char *bp; - int n, size, type, len; + int n, size, type, len, use_malloc = 0; + struct hostent *ret; extern struct hostent *_gethtbyname2(); if ((_res.options & RES_INIT) == 0 && __res_ninit(&_res) == -1) { @@ -615,13 +616,26 @@ gethostbyname2(name, af) break; } - if ((n = res_nsearch(&_res, name, C_IN, type, buf.buf, sizeof(buf.buf))) < 0) { + if (!__libc_use_alloca (MAXPACKET)) { + buf = (querybuf *) malloc (sizeof (*buf)); + if (buf == NULL) { + __set_h_errno (NETDB_INTERNAL); + return NULL; + } + use_malloc = 1; + } else + buf = (querybuf *) alloca (sizeof (*buf)); + + if ((n = res_nsearch(&_res, name, C_IN, type, buf->buf, sizeof(buf->buf))) < 0) { dprintf("res_nsearch failed (%d)\n", n); if (errno == ECONNREFUSED) return (_gethtbyname2(name, af)); return (NULL); } - return (getanswer(&buf, n, name, type)); + ret = getanswer(buf, n, name, type); + if (use_malloc) + free (buf); + return ret; } struct hostent * @@ -633,9 +647,9 @@ gethostbyaddr(addr, len, af) const u_char *uaddr = (const u_char *)addr; static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 }; - int n; + int n, use_malloc = 0; socklen_t size; - querybuf buf; + querybuf *buf; register struct hostent *hp; char qbuf[MAXDNAME+1], *qp = NULL; #ifdef SUNSECURITY @@ -696,18 +710,34 @@ gethostbyaddr(addr, len, af) default: abort(); } - n = res_nquery(&_res, qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf); + + if (!__libc_use_alloca (MAXPACKET)) { + buf = (querybuf *) malloc (sizeof (*buf)); + if (buf == NULL) { + __set_h_errno (NETDB_INTERNAL); + return NULL; + } + use_malloc = 1; + } else + buf = (querybuf *) alloca (sizeof (*buf)); + + n = res_nquery(&_res, qbuf, C_IN, T_PTR, buf->buf, sizeof buf->buf); if (n < 0 && af == AF_INET6) { strcpy(qp, "ip6.int"); - n = res_nquery(&_res, qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf); + n = res_nquery(&_res, qbuf, C_IN, T_PTR, buf->buf, sizeof buf->buf); } if (n < 0) { + if (use_malloc) + free (buf); dprintf("res_nquery failed (%d)\n", n); if (errno == ECONNREFUSED) return (_gethtbyaddr(addr, len, af)); return (NULL); } - if (!(hp = getanswer(&buf, n, qbuf, T_PTR))) + hp = getanswer(buf, n, qbuf, T_PTR); + if (use_malloc) + free (buf); + if (!hp) return (NULL); /* h_errno was set by getanswer() */ #ifdef SUNSECURITY if (af == AF_INET) { |