Print this page
1926 libresolv evades compiler warnings

*** 18,27 **** --- 18,28 ---- * * CDDL HEADER END */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
*** 35,55 **** * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ - #pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> #include <errno.h> #include <netdb.h> /* * Kludge to time out quickly if there is no /etc/resolv.conf * and a TCP connection to the local DNS server fails. * --- 36,58 ---- * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> + #include <string.h> + #include <stdlib.h> + #include <unistd.h> #include <errno.h> #include <netdb.h> + #include "crossl.h" /* * Kludge to time out quickly if there is no /etc/resolv.conf * and a TCP connection to the local DNS server fails. *
*** 95,109 **** ns = socket(AF_INET, SOCK_STREAM, 0); IN_SET_LOOPBACK_ADDR(&ns_sin); ns_sin.sin_port = htons(NAMESERVER_PORT); if (connect(ns, (struct sockaddr *) &ns_sin, sizeof ns_sin) == -1) { ! close(ns); return(-1); } else { ! close(ns); return(0); } } return(0); --- 98,112 ---- ns = socket(AF_INET, SOCK_STREAM, 0); IN_SET_LOOPBACK_ADDR(&ns_sin); ns_sin.sin_port = htons(NAMESERVER_PORT); if (connect(ns, (struct sockaddr *) &ns_sin, sizeof ns_sin) == -1) { ! (void) close(ns); return(-1); } else { ! (void) close(ns); return(0); } } return(0);
*** 126,138 **** struct rrec *newrr; /* new rr for modify or append */ char *buf; /* buffer to put query */ int buflen; /* size of buffer */ { register HEADER *hp; ! register char *cp; register int n; ! char *dnptrs[10], **dpp, **lastdnptr; #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type); #endif /* DEBUG */ --- 129,141 ---- struct rrec *newrr; /* new rr for modify or append */ char *buf; /* buffer to put query */ int buflen; /* size of buffer */ { register HEADER *hp; ! register u_char *cp; register int n; ! u_char *dnptrs[10], **dpp, **lastdnptr; #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type); #endif /* DEBUG */
*** 157,190 **** * Initialize header fields. */ if ((buf == NULL) || (buflen < sizeof (HEADER))) return (-1); #ifdef SYSV ! memset(buf, 0, sizeof (HEADER)); #else bzero(buf, sizeof (HEADER)); #endif hp = (HEADER *) buf; hp->id = htons(++_res.id); hp->opcode = op; hp->pr = (_res.options & RES_PRIMARY) != 0; hp->rd = (_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; ! cp = buf + sizeof (HEADER); buflen -= sizeof (HEADER); dpp = dnptrs; ! *dpp++ = buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof (dnptrs) / sizeof (dnptrs[0]); /* * perform opcode specific processing */ switch (op) { case QUERY: if ((buflen -= QFIXEDSZ) < 0) return (-1); ! if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(type, cp); cp += sizeof (u_short); --- 160,194 ---- * Initialize header fields. */ if ((buf == NULL) || (buflen < sizeof (HEADER))) return (-1); #ifdef SYSV ! (void) memset(buf, 0, sizeof (HEADER)); #else bzero(buf, sizeof (HEADER)); #endif hp = (HEADER *) buf; hp->id = htons(++_res.id); hp->opcode = op; hp->pr = (_res.options & RES_PRIMARY) != 0; hp->rd = (_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; ! cp = (u_char *)(buf + sizeof (HEADER)); buflen -= sizeof (HEADER); dpp = dnptrs; ! *dpp++ = (u_char *)buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof (dnptrs) / sizeof (dnptrs[0]); /* * perform opcode specific processing */ switch (op) { case QUERY: if ((buflen -= QFIXEDSZ) < 0) return (-1); ! if ((n = dn_comp((u_char *)dname, cp, buflen, ! dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(type, cp); cp += sizeof (u_short);
*** 195,205 **** break; /* * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; ! if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(T_NULL, cp); cp += sizeof (u_short); --- 199,210 ---- break; /* * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; ! if ((n = dn_comp((u_char *)data, cp, buflen, ! dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(T_NULL, cp); cp += sizeof (u_short);
*** 227,237 **** cp += sizeof (u_long); putshort(datalen, cp); cp += sizeof (u_short); if (datalen) { #ifdef SYSV ! memcpy((void *)cp, (void *)data, datalen); #else bcopy(data, cp, datalen); #endif cp += datalen; } --- 232,242 ---- cp += sizeof (u_long); putshort(datalen, cp); cp += sizeof (u_short); if (datalen) { #ifdef SYSV ! (void) memcpy((void *)cp, (void *)data, datalen); #else bcopy(data, cp, datalen); #endif cp += datalen; }
*** 252,262 **** * calls them differently: specifies data for UPDATED; server * ignores data if specified for UPDATEDA. */ case UPDATEDA: buflen -= RRFIXEDSZ + datalen; ! if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(type, cp); cp += sizeof (u_short); putshort(class, cp); --- 257,268 ---- * calls them differently: specifies data for UPDATED; server * ignores data if specified for UPDATEDA. */ case UPDATEDA: buflen -= RRFIXEDSZ + datalen; ! if ((n = dn_comp((u_char *)dname, cp, buflen, ! dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(type, cp); cp += sizeof (u_short); putshort(class, cp);
*** 279,289 **** } /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ case UPDATEA: /* Add new resource record */ buflen -= RRFIXEDSZ + datalen; ! if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(newrr->r_type, cp); cp += sizeof (u_short); putshort(newrr->r_class, cp); --- 285,296 ---- } /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ case UPDATEA: /* Add new resource record */ buflen -= RRFIXEDSZ + datalen; ! if ((n = dn_comp((u_char *)dname, cp, buflen, ! dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(newrr->r_type, cp); cp += sizeof (u_short); putshort(newrr->r_class, cp);
*** 303,309 **** hp->ancount = htons(0); break; #endif /* ALLOW_UPDATES */ } ! return (cp - buf); } --- 310,316 ---- hp->ancount = htons(0); break; #endif /* ALLOW_UPDATES */ } ! return ((char *)cp - buf); }