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.4 (requested by it...



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

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

diffstat:

 dist/bind/lib/isc/ctl_srvr.c |  70 ++++++++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 21 deletions(-)

diffs (197 lines):

diff -r 6c7e0881224a -r 25453af09ddd dist/bind/lib/isc/ctl_srvr.c
--- a/dist/bind/lib/isc/ctl_srvr.c      Fri Jun 28 11:54:41 2002 +0000
+++ b/dist/bind/lib/isc/ctl_srvr.c      Fri Jun 28 11:54:49 2002 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: ctl_srvr.c,v 1.3 2001/01/27 07:22:04 itojun Exp $      */
+/*     $NetBSD: ctl_srvr.c,v 1.3.2.1 2002/06/28 11:54:49 lukem Exp $   */
 
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "Id: ctl_srvr.c,v 8.24 2000/11/14 01:10:37 vixie Exp";
+static const char rcsid[] = "Id: ctl_srvr.c,v 8.25 2001/05/29 05:49:27 marka Exp";
 #endif /* not lint */
 
 /*
@@ -94,7 +94,7 @@
        struct ctl_buf          outbuf;
        const struct ctl_verb * verb;
        u_int                   helpcode;
-       void *                  respctx;
+       const void *            respctx;
        u_int                   respflags;
        ctl_srvrdone            donefunc;
        void *                  uap;
@@ -141,7 +141,7 @@
                                             struct ctl_sess *,
                                             const struct ctl_verb *,
                                             const char *,
-                                            u_int, void *, void *);
+                                            u_int, const void *, void *);
 static void                    ctl_signal_done(struct ctl_sctx *,
                                                struct ctl_sess *);
 
@@ -154,7 +154,9 @@
 
 static const char              space[] = " ";
 
-static const struct ctl_verb   fakehelpverb = { "fakehelp", ctl_morehelp };
+static const struct ctl_verb   fakehelpverb = {
+       "fakehelp", ctl_morehelp , NULL
+};
 
 /* Public. */
 
@@ -227,7 +229,7 @@
        if (sap->sa_family != AF_UNIX)
 #endif
                if (setsockopt(ctx->sock, SOL_SOCKET, SO_REUSEADDR,
-                              (char *)&on, sizeof on) != 0) {
+                              (const char *)&on, sizeof on) != 0) {
                        (*ctx->logger)(ctl_warning,
                                       "%s: setsockopt(REUSEADDR): %s",
                                       me, strerror(errno));
@@ -236,7 +238,7 @@
                char tmp[MAX_NTOP];
                save_errno = errno;
                (*ctx->logger)(ctl_error, "%s: bind: %s: %s",
-                              me, ctl_sa_ntop((struct sockaddr *)sap,
+                              me, ctl_sa_ntop((const struct sockaddr *)sap,
                               tmp, sizeof tmp, ctx->logger),
                               strerror(save_errno));
                close(ctx->sock);
@@ -297,8 +299,8 @@
  */
 void
 ctl_response(struct ctl_sess *sess, u_int code, const char *text,
-            u_int flags, void *respctx, ctl_srvrdone donefunc, void *uap,
-            const char *body, size_t bodylen)
+            u_int flags, const void *respctx, ctl_srvrdone donefunc,
+            void *uap, const char *body, size_t bodylen)
 {
        static const char me[] = "ctl_response";
        struct iovec iov[3], *iovp = iov;
@@ -329,13 +331,18 @@
        sess->outbuf.used = SPRINTF((sess->outbuf.text, "%03d%c%s\r\n",
                                     code, (flags & CTL_MORE) != 0 ? '-' : ' ',
                                     text));
-       for (pc = sess->outbuf.text, n = 0; n < sess->outbuf.used-2; pc++, n++)
-               if (!isascii(*pc) || !isprint(*pc))
+       for (pc = sess->outbuf.text, n = 0;
+            n < (int)sess->outbuf.used-2; pc++, n++)
+               if (!isascii((unsigned char)*pc) ||
+                   !isprint((unsigned char)*pc))
                        *pc = '\040';
        *iovp++ = evConsIovec(sess->outbuf.text, sess->outbuf.used);
        if (body != NULL) {
-               *iovp++ = evConsIovec((char *)body, bodylen);
-               *iovp++ = evConsIovec(".\r\n", 3);
+               char *tmp;
+               DE_CONST(body, tmp);
+               *iovp++ = evConsIovec(tmp, bodylen);
+               DE_CONST(".\r\n", tmp);
+               *iovp++ = evConsIovec(tmp, 3);
        }
        (*ctx->logger)(ctl_debug, "%s: [%d] %s", me,
                       sess->outbuf.used, sess->outbuf.text);
@@ -371,7 +378,8 @@
 
        sess->helpcode = code;
        sess->verb = &fakehelpverb;
-       ctl_morehelp(ctx, sess, NULL, me, CTL_MORE, (void *)ctx->verbs, NULL);
+       ctl_morehelp(ctx, sess, NULL, me, CTL_MORE,
+                    (const void *)ctx->verbs, NULL);
 }
 
 void *
@@ -399,6 +407,10 @@
        struct ctl_sess *sess = NULL;
        char tmp[MAX_NTOP];
 
+       UNUSED(lev);
+       UNUSED(lalen);
+       UNUSED(ralen);
+
        if (fd < 0) {
                (*ctx->logger)(ctl_error, "%s: accept: %s",
                               me, strerror(errno));
@@ -406,7 +418,7 @@
        }
        if (ctx->cur_sess == ctx->max_sess) {
                (*ctx->logger)(ctl_error, "%s: %s: too many control sessions",
-                              me, ctl_sa_ntop((struct sockaddr *)rav,
+                              me, ctl_sa_ntop((const struct sockaddr *)rav,
                                               tmp, sizeof tmp,
                                               ctx->logger));
                (void) close(fd);
@@ -434,11 +446,11 @@
        sess->rdtiID.opaque = NULL;
        sess->respctx = NULL;
        sess->csctx = NULL;
-       if (((struct sockaddr *)rav)->sa_family == AF_UNIX)
-               ctl_sa_copy((struct sockaddr *)lav,
+       if (((const struct sockaddr *)rav)->sa_family == AF_UNIX)
+               ctl_sa_copy((const struct sockaddr *)lav,
                            (struct sockaddr *)&sess->sa);
        else
-               ctl_sa_copy((struct sockaddr *)rav,
+               ctl_sa_copy((const struct sockaddr *)rav,
                            (struct sockaddr *)&sess->sa);
        sess->donefunc = NULL;
        buffer_init(sess->inbuf);
@@ -449,7 +461,7 @@
        (*ctx->logger)(ctl_debug, "%s: %s: accepting (fd %d)",
                       me, address_expr, sess->sock);
        (*ctx->connverb->func)(ctx, sess, ctx->connverb, "", 0,
-                              (struct sockaddr *)rav, ctx->uctx);
+                              (const struct sockaddr *)rav, ctx->uctx);
 }
 
 static void
@@ -616,6 +628,10 @@
        struct ctl_sess *sess = uap;
        struct ctl_sctx *ctx = sess->ctx;
        char tmp[MAX_NTOP];
+       
+       UNUSED(lev);
+       UNUSED(due);
+       UNUSED(itv);
 
        REQUIRE(sess->state == writing);
        sess->wrtiID.opaque = NULL;
@@ -640,6 +656,10 @@
        struct ctl_sctx *ctx = sess->ctx;
        char tmp[MAX_NTOP];
 
+       UNUSED(lev);
+       UNUSED(due);
+       UNUSED(itv);
+
        REQUIRE(sess->state == reading);
        sess->rdtiID.opaque = NULL;
        (*ctx->logger)(ctl_warning, "%s: %s: timeout, closing",
@@ -701,6 +721,9 @@
        char tmp[MAX_NTOP];
        int save_errno = errno;
 
+       UNUSED(lev);
+       UNUSED(uap);
+
        REQUIRE(sess->state == writing);
        REQUIRE(fd == sess->sock);
        REQUIRE(sess->wrtiID.opaque != NULL);
@@ -733,9 +756,14 @@
 static void
 ctl_morehelp(struct ctl_sctx *ctx, struct ctl_sess *sess,
             const struct ctl_verb *verb, const char *text,
-            u_int respflags, void *respctx, void *uctx)
+            u_int respflags, const void *respctx, void *uctx)
 {
-       struct ctl_verb *this = respctx, *next = this + 1;
+       const struct ctl_verb *this = respctx, *next = this + 1;
+
+       UNUSED(ctx);
+       UNUSED(verb);
+       UNUSED(text);
+       UNUSED(uctx);
 
        REQUIRE(!lastverb_p(this));
        REQUIRE((respflags & CTL_MORE) != 0);



Home | Main Index | Thread Index | Old Index