Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/lib/libc/net Pull up revision 1.24 (requested by itojun...
details: https://anonhg.NetBSD.org/src/rev/9ad32726bb71
branches: netbsd-1-6
changeset: 529038:9ad32726bb71
user: lukem <lukem%NetBSD.org@localhost>
date: Tue Aug 27 09:23:44 2002 +0000
description:
Pull up revision 1.24 (requested by itojun in ticket #735):
allocate 64K recieve buffer for DNS responses.
diffstat:
lib/libc/net/getnetnamadr.c | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diffs (103 lines):
diff -r f1b793244ce4 -r 9ad32726bb71 lib/libc/net/getnetnamadr.c
--- a/lib/libc/net/getnetnamadr.c Tue Aug 27 09:23:35 2002 +0000
+++ b/lib/libc/net/getnetnamadr.c Tue Aug 27 09:23:44 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getnetnamadr.c,v 1.20.4.2 2002/08/17 15:45:39 lukem Exp $ */
+/* $NetBSD: getnetnamadr.c,v 1.20.4.3 2002/08/27 09:23:44 lukem Exp $ */
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
@@ -47,7 +47,7 @@
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
static char rcsid[] = "Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: getnetnamadr.c,v 1.20.4.2 2002/08/17 15:45:39 lukem Exp $");
+__RCSID("$NetBSD: getnetnamadr.c,v 1.20.4.3 2002/08/27 09:23:44 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -92,11 +92,7 @@
#define BYNAME 1
#define MAXALIASES 35
-#if PACKETSZ > 1024
-#define MAXPACKET PACKETSZ
-#else
-#define MAXPACKET 1024
-#endif
+#define MAXPACKET (64*1024)
typedef union {
HEADER hdr;
@@ -281,7 +277,7 @@
{
unsigned int netbr[4];
int nn, anslen;
- querybuf buf;
+ querybuf *buf;
char qbuf[MAXDNAME];
unsigned long net2;
struct netent *np;
@@ -317,16 +313,22 @@
netbr[3], netbr[2], netbr[1], netbr[0]);
break;
}
- anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
- sizeof(buf));
+ buf = malloc(sizeof(*buf));
+ if (buf == NULL) {
+ h_errno = NETDB_INTERNAL;
+ return NS_NOTFOUND;
+ }
+ anslen = res_query(qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
if (anslen < 0) {
+ free(buf);
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf("res_query failed\n");
#endif
return NS_NOTFOUND;
}
- np = getnetanswer(&buf, anslen, BYADDR);
+ np = getnetanswer(buf, anslen, BYADDR);
+ free(buf);
if (np) {
/* maybe net should be unsigned? */
unsigned long u_net = net;
@@ -413,7 +415,7 @@
va_list ap;
{
int anslen;
- querybuf buf;
+ querybuf *buf;
char qbuf[MAXDNAME];
struct netent *np;
const char *net;
@@ -422,17 +424,22 @@
net = va_arg(ap, const char *);
strcpy(&qbuf[0], net);
- anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)(void *)&buf,
- sizeof(buf));
+ buf = malloc(sizeof(*buf));
+ if (buf == NULL) {
+ h_errno = NETDB_INTERNAL;
+ return NS_NOTFOUND;
+ }
+ anslen = res_search(qbuf, C_IN, T_PTR, buf->buf, sizeof(buf->buf));
if (anslen < 0) {
+ free(buf);
#ifdef DEBUG
if (_res.options & RES_DEBUG)
- printf("res_query failed\n");
+ printf("res_search failed\n");
#endif
return NS_NOTFOUND;
}
- np = getnetanswer(&buf, anslen, BYNAME);
-
+ np = getnetanswer(buf, anslen, BYNAME);
+ free(buf);
*((struct netent **)rv) = np;
if (np == NULL) {
h_errno = HOST_NOT_FOUND;
Home |
Main Index |
Thread Index |
Old Index