Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/dist/bind/lib/isc Pull up revision 1.3 (requested by it...



details:   https://anonhg.NetBSD.org/src/rev/4d82a5a30e0a
branches:  netbsd-1-6
changeset: 528223:4d82a5a30e0a
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Jun 28 11:54:31 2002 +0000

description:
Pull up revision 1.3 (requested by itojun in ticket #387):
Update to BIND 8.3.3.  Fixes buffer overrun in resolver code.

diffstat:

 dist/bind/lib/isc/ctl_p.c |  42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diffs (79 lines):

diff -r 805439e12dfa -r 4d82a5a30e0a dist/bind/lib/isc/ctl_p.c
--- a/dist/bind/lib/isc/ctl_p.c Fri Jun 28 11:54:22 2002 +0000
+++ b/dist/bind/lib/isc/ctl_p.c Fri Jun 28 11:54:31 2002 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: ctl_p.c,v 1.2 2001/01/27 07:22:04 itojun Exp $ */
+/*     $NetBSD: ctl_p.c,v 1.2.2.1 2002/06/28 11:54:31 lukem Exp $      */
 
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "Id: ctl_p.c,v 8.7 2000/02/04 08:28:33 vixie Exp";
+static const char rcsid[] = "Id: ctl_p.c,v 8.8 2001/05/29 05:49:26 marka Exp";
 #endif /* not lint */
 
 /*
@@ -106,11 +106,30 @@
 {
        static const char me[] = "ctl_sa_ntop";
        static const char punt[] = "[0].-1";
-       char tmp[sizeof "255.255.255.255"];
+       char tmp[INET6_ADDRSTRLEN];
 
        switch (sa->sa_family) {
+       case AF_INET6: {
+               const struct sockaddr_in6 *in6 =
+                                       (const struct sockaddr_in6 *) sa;
+
+               if (inet_ntop(in6->sin6_family, &in6->sin6_addr, tmp, sizeof tmp)
+                   == NULL) {
+                       (*logger)(ctl_error, "%s: inet_ntop(%u %04x): %s",
+                                 me, in6->sin6_family,
+                                 in6->sin6_port, strerror(errno));
+                       return (punt);
+               }
+               if (strlen(tmp) + sizeof "[].65535" > size) {
+                       (*logger)(ctl_error, "%s: buffer overflow", me);
+                       return (punt);
+               }
+               (void) sprintf(buf, "[%s].%u", tmp, ntohs(in6->sin6_port));
+               return (buf);
+           }
        case AF_INET: {
-               const struct sockaddr_in *in = (struct sockaddr_in *) sa;
+               const struct sockaddr_in *in =
+                                             (const struct sockaddr_in *) sa;
 
                if (inet_ntop(in->sin_family, &in->sin_addr, tmp, sizeof tmp)
                    == NULL) {
@@ -129,8 +148,9 @@
            }
 #ifndef NO_SOCKADDR_UN
        case AF_UNIX: {
-               const struct sockaddr_un *un = (struct sockaddr_un *) sa;
-               int x = sizeof un->sun_path;
+               const struct sockaddr_un *un = 
+                                             (const struct sockaddr_un *) sa;
+               unsigned int x = sizeof un->sun_path;
 
                if (x > size)
                        x = size;
@@ -147,12 +167,18 @@
 void
 ctl_sa_copy(const struct sockaddr *src, struct sockaddr *dst) {
        switch (src->sa_family) {
+       case AF_INET6:
+               *((struct sockaddr_in6 *)dst) =
+                                        *((const struct sockaddr_in6 *)src);
+               break;
        case AF_INET:
-               *((struct sockaddr_in *)dst) =  *((struct sockaddr_in *)src);
+               *((struct sockaddr_in *)dst) =
+                                         *((const struct sockaddr_in *)src);
                break;
 #ifndef NO_SOCKADDR_UN
        case AF_UNIX:
-               *((struct sockaddr_un *)dst) =  *((struct sockaddr_un *)src);
+               *((struct sockaddr_un *)dst) =
+                                         *((const struct sockaddr_un *)src);
                break;
 #endif
        default:



Home | Main Index | Thread Index | Old Index