Date: Wed, 11 Sep 2002 10:34:07 -0500 From: "Jacques A. Vidrine" <nectar@FreeBSD.org> To: freebsd-audit@FreeBSD.org Subject: res_send/res_query/res_search Message-ID: <20020911153407.GA3486@madman.nectar.cc>
next in thread | raw e-mail | index | archive | help
Hello, When using res_send/res_query/res_search, the caller must either (1) insure enough space is available for the response (up to 64K) OR (2) check the return value and retry the request with a bigger buffer if the return value is larger than the buffer size A simple patch for (1) is included below. Please review. I'd like to commit this now, while if in some areas doing (2) is somehow better, then that can be followed up. Cheers! Index: net/getaddrinfo.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/getaddrinfo.c,v retrieving revision 1.9.2.9 diff -c -I\$FreeBSD -r1.9.2.9 getaddrinfo.c *** net/getaddrinfo.c 3 Mar 2002 18:45:30 -0000 1.9.2.9 --- net/getaddrinfo.c 6 Sep 2002 12:48:58 -0000 *************** *** 182,192 **** #define PTON_MAX 4 #endif ! #if PACKETSZ > 1024 ! #define MAXPACKET PACKETSZ ! #else ! #define MAXPACKET 1024 ! #endif typedef union { HEADER hdr; --- 182,188 ---- #define PTON_MAX 4 #endif ! #define MAXPACKET 65536 typedef union { HEADER hdr; Index: net/gethostbydns.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/gethostbydns.c,v retrieving revision 1.27.2.2 diff -c -I\$FreeBSD -r1.27.2.2 gethostbydns.c *** net/gethostbydns.c 26 Jun 2002 06:24:29 -0000 1.27.2.2 --- net/gethostbydns.c 6 Sep 2002 12:46:32 -0000 *************** *** 96,106 **** static void addrsort __P((char **, int)); #endif ! #if PACKETSZ > 1024 ! #define MAXPACKET PACKETSZ ! #else ! #define MAXPACKET 1024 ! #endif typedef union { HEADER hdr; --- 96,102 ---- static void addrsort __P((char **, int)); #endif ! #define MAXPACKET 65536 typedef union { HEADER hdr; Index: net/getnetbydns.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/getnetbydns.c,v retrieving revision 1.13.2.2 diff -c -I\$FreeBSD -r1.13.2.2 getnetbydns.c *** net/getnetbydns.c 26 Jun 2002 06:34:18 -0000 1.13.2.2 --- net/getnetbydns.c 6 Sep 2002 12:53:19 -0000 *************** *** 85,95 **** #define BYNAME 1 #define MAXALIASES 35 ! #if PACKETSZ > 1024 ! #define MAXPACKET PACKETSZ ! #else ! #define MAXPACKET 1024 ! #endif typedef union { HEADER hdr; --- 85,91 ---- #define BYNAME 1 #define MAXALIASES 35 ! #define MAXPACKET 65536 typedef union { HEADER hdr; Index: net/name6.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/name6.c,v retrieving revision 1.6.2.6 diff -c -I\$FreeBSD -r1.6.2.6 name6.c *** net/name6.c 26 Jun 2002 06:06:43 -0000 1.6.2.6 --- net/name6.c 6 Sep 2002 12:47:21 -0000 *************** *** 994,1004 **** int rtl_type; }; ! #if PACKETSZ > 1024 ! #define MAXPACKET PACKETSZ ! #else ! #define MAXPACKET 1024 ! #endif typedef union { HEADER hdr; --- 994,1000 ---- int rtl_type; }; ! #define MAXPACKET 65536 typedef union { HEADER hdr; Index: net/res_query.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/res_query.c,v retrieving revision 1.19.2.2 diff -c -I\$FreeBSD -r1.19.2.2 res_query.c *** net/res_query.c 7 Jul 2002 11:34:42 -0000 1.19.2.2 --- net/res_query.c 6 Sep 2002 12:54:01 -0000 *************** *** 89,99 **** #include "res_config.h" ! #if PACKETSZ > 1024 ! #define MAXPACKET PACKETSZ ! #else ! #define MAXPACKET 1024 ! #endif /* * Formulate a normal query, send, and await answer. --- 89,95 ---- #include "res_config.h" ! #define MAXPACKET 65536 /* * Formulate a normal query, send, and await answer. Index: net/res_update.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/res_update.c,v retrieving revision 1.2.2.1 diff -c -I\$FreeBSD -r1.2.2.1 res_update.c *** net/res_update.c 5 Mar 2001 10:47:11 -0000 1.2.2.1 --- net/res_update.c 6 Sep 2002 12:50:57 -0000 *************** *** 52,57 **** --- 52,58 ---- */ #define NSMAX 16 + #define MAXPACKET 65536 struct ns1 { char nsname[MAXDNAME]; *************** *** 72,78 **** int res_update(ns_updrec *rrecp_in) { ns_updrec *rrecp, *tmprrecp; ! u_char buf[PACKETSZ], answer[PACKETSZ], packet[2*PACKETSZ]; char name[MAXDNAME], zname[MAXDNAME], primary[MAXDNAME], mailaddr[MAXDNAME]; u_char soardata[2*MAXCDNAME+5*INT32SZ]; --- 73,79 ---- int res_update(ns_updrec *rrecp_in) { ns_updrec *rrecp, *tmprrecp; ! u_char buf[PACKETSZ], answer[MAXPACKET], packet[2*PACKETSZ]; char name[MAXDNAME], zname[MAXDNAME], primary[MAXDNAME], mailaddr[MAXDNAME]; u_char soardata[2*MAXCDNAME+5*INT32SZ]; -- Jacques A. Vidrine <nectar@celabo.org> http://www.celabo.org/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020911153407.GA3486>