BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / named / ns_resp.c
index bac4721..c016c02 100644 (file)
@@ -2,26 +2,39 @@
  * Copyright (c) 1986, 1988, 1990 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1986, 1988, 1990 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ns_resp.c  4.63 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)ns_resp.c  4.65 (Berkeley) 3/3/91";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <stdio.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/socket.h>
@@ -29,6 +42,8 @@ static char sccsid[] = "@(#)ns_resp.c 4.63 (Berkeley) 6/1/90";
 #include <netinet/in.h>
 #include <syslog.h>
 #include <arpa/nameser.h>
 #include <netinet/in.h>
 #include <syslog.h>
 #include <arpa/nameser.h>
+#include <resolv.h>
+#include <stdio.h>
 #include "ns.h"
 #include "db.h"
 
 #include "ns.h"
 #include "db.h"
 
@@ -490,7 +505,7 @@ ns_resp(msg, msglen)
        if (cname)
                cp += dn_skipname(cp, newmsg + newmsglen) + QFIXEDSZ;
        if ((n = dn_expand(newmsg, newmsg + newmsglen,
        if (cname)
                cp += dn_skipname(cp, newmsg + newmsglen) + QFIXEDSZ;
        if ((n = dn_expand(newmsg, newmsg + newmsglen,
-               cp, dname, sizeof(name))) < 0) {
+               cp, (u_char *)dname, sizeof(name))) < 0) {
 #ifdef DEBUG
                if (debug)
                        fprintf(ddt,"dn_expand failed\n" );
 #ifdef DEBUG
                if (debug)
                        fprintf(ddt,"dn_expand failed\n" );
@@ -659,7 +674,7 @@ fetch_ns:
                        ntohs(qp->q_nsid), ntohs(qp->q_id),
                        qp->q_addr[0].nsdata->d_nstime);
        if ( debug >= 10)
                        ntohs(qp->q_nsid), ntohs(qp->q_id),
                        qp->q_addr[0].nsdata->d_nstime);
        if ( debug >= 10)
-               fp_query(msg, ddt);
+               fp_query((char *)msg, ddt);
 #endif
        if (sendto(ds, qp->q_msg, qp->q_msglen, 0,
                (struct sockaddr *)Q_NEXTADDR(qp,0),
 #endif
        if (sendto(ds, qp->q_msg, qp->q_msglen, 0,
                (struct sockaddr *)Q_NEXTADDR(qp,0),
@@ -769,7 +784,8 @@ doupdate(msg, msglen, rrp, zone, savens, flags)
 #endif
 
        cp = rrp;
 #endif
 
        cp = rrp;
-       if ((n = dn_expand(msg, msg + msglen, cp, dname, sizeof(dname))) < 0) {
+       if ((n = dn_expand((u_char *)msg, (u_char *)msg + msglen, cp,
+           (u_char *)dname, sizeof(dname))) < 0) {
                hp->rcode = FORMERR;
                return (-1);
        }
                hp->rcode = FORMERR;
                return (-1);
        }
@@ -809,34 +825,35 @@ doupdate(msg, msglen, rrp, zone, savens, flags)
        case T_MR:
        case T_NS:
        case T_PTR:
        case T_MR:
        case T_NS:
        case T_PTR:
-               if ((n = dn_expand(msg, msg + msglen, cp, data,
-                  sizeof(data))) < 0) {
+               if ((n = dn_expand((u_char *)msg, (u_char *)msg + msglen,
+                   cp, data, sizeof(data))) < 0) {
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
                cp1 = data;
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
                cp1 = data;
-               n = strlen(data) + 1;
+               n = strlen((char *)data) + 1;
                break;
 
        case T_MINFO:
        case T_SOA:
                break;
 
        case T_MINFO:
        case T_SOA:
-               if ((n = dn_expand(msg, msg + msglen, cp, data,
-                   sizeof(data))) < 0) {
+               if ((n = dn_expand((u_char *)msg, (u_char *)msg + msglen,
+                   cp, data, sizeof(data))) < 0) {
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
-               cp1 = data + (n = strlen(data) + 1);
+               cp1 = data + (n = strlen((char *)data) + 1);
                n1 = sizeof(data) - n;
                if (type == T_SOA)
                        n1 -= 5 * sizeof(u_long);
                n1 = sizeof(data) - n;
                if (type == T_SOA)
                        n1 -= 5 * sizeof(u_long);
-               if ((n = dn_expand(msg, msg + msglen, cp, cp1, n1)) < 0) {
+               if ((n = dn_expand((u_char *)msg, (u_char *)msg + msglen,
+                   cp, cp1, n1)) < 0) {
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
                        hp->rcode = FORMERR;
                        return (-1);
                }
                cp += n;
-               cp1 += strlen(cp1) + 1;
+               cp1 += strlen((char *)cp1) + 1;
                if (type == T_SOA) {
                        bcopy(cp, cp1, n = 5 * sizeof(u_long));
                        cp += n;
                if (type == T_SOA) {
                        bcopy(cp, cp1, n = 5 * sizeof(u_long));
                        cp += n;
@@ -853,13 +870,13 @@ doupdate(msg, msglen, rrp, zone, savens, flags)
                cp += sizeof(u_short);
 
                /* get name */
                cp += sizeof(u_short);
 
                /* get name */
-               if ((n = dn_expand(msg, msg + msglen, cp, cp1,
-                   sizeof(data)-sizeof(u_short))) < 0)
+               if ((n = dn_expand((u_char *)msg, (u_char *)msg + msglen,
+                   cp, cp1, sizeof(data) - sizeof(u_short))) < 0)
                        return(-1);
                cp += n;
 
                /* compute end of data */
                        return(-1);
                cp += n;
 
                /* compute end of data */
-               cp1 += strlen(cp1) + 1;
+               cp1 += strlen((char *)cp1) + 1;
                /* compute size of data */
                n = cp1 - data;
                cp1 = data;
                /* compute size of data */
                n = cp1 - data;
                cp1 = data;
@@ -1122,8 +1139,10 @@ prime(class, type, oqp)
 
        if (oqp->q_msg == NULL)
                return;
 
        if (oqp->q_msg == NULL)
                return;
-       if (dn_expand(oqp->q_msg, oqp->q_msg + oqp->q_msglen,
-           oqp->q_msg + sizeof(HEADER), dname, sizeof(dname)) < 0)
+       if (dn_expand((u_char *)oqp->q_msg,
+           (u_char *)oqp->q_msg + oqp->q_msglen,
+           (u_char *)oqp->q_msg + sizeof(HEADER), (u_char *)dname,
+           sizeof(dname)) < 0)
                return;
 #ifdef DEBUG
        if (debug >= 2)
                return;
 #ifdef DEBUG
        if (debug >= 2)