]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace all usage of inet_aton() with inet_pton()
authorOndřej Surý <ondrej@sury.org>
Mon, 30 Oct 2017 14:38:23 +0000 (15:38 +0100)
committerMichał Kępień <michal@isc.org>
Fri, 23 Feb 2018 12:57:10 +0000 (13:57 +0100)
12 files changed:
lib/dns/master.c
lib/dns/rdata.c
lib/dns/rdata/generic/mx_15.c
lib/irs/resconf.c
lib/isc/Makefile.in
lib/isc/inet_aton.c [deleted file]
lib/isc/unix/include/isc/net.h
lib/isc/win32/include/isc/net.h
lib/isc/win32/libisc.vcxproj.filters.in
lib/isc/win32/libisc.vcxproj.in
lib/ns/update.c
util/copyrights

index 634a2c0dffdb2d8b3eb0d0d67a7a644015e04e6d..e2a1f70b61e54e1f2930300518d285dbf48528d3 100644 (file)
@@ -978,7 +978,7 @@ check_ns(dns_loadctx_t *lctx, isc_token_t *token, const char *source,
                 */
                if (tmp[strlen(tmp) - 1] == '.')
                        tmp[strlen(tmp) - 1] = '\0';
-               if (inet_aton(tmp, &addr) == 1 ||
+               if (inet_pton(AF_INET, tmp, &addr) == 1 ||
                    inet_pton(AF_INET6, tmp, &addr6) == 1)
                        result = DNS_R_NSISADDRESS;
        }
index 38096bba06ec458d7cafd8394401dced19b97d9c..e72b49909a44633f0d9e3e4b74b06ba07ea1e471 100644 (file)
@@ -383,11 +383,9 @@ getquad(const void *src, struct in_addr *dst,
        isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks)
 {
        int result;
-       struct in_addr tmp;
 
-       result = inet_aton(src, dst);
-       if (result == 1 && callbacks != NULL &&
-           inet_pton(AF_INET, src, &tmp) != 1) {
+       result = inet_pton(AF_INET, src, dst);
+       if (result != 1 && callbacks != NULL) {
                const char *name = isc_lex_getsourcename(lexer);
                if (name == NULL)
                        name = "UNKNOWN";
index 652e3044467407cd0947a6bfdceb73bf8aa0b725..dfc9a7ab1a82ef77baf06298d7ff981622ed1411 100644 (file)
@@ -35,9 +35,10 @@ check_mx(isc_token_t *token) {
 
        if (tmp[strlen(tmp) - 1] == '.')
                tmp[strlen(tmp) - 1] = '\0';
-       if (inet_aton(tmp, &addr) == 1 ||
-           inet_pton(AF_INET6, tmp, &addr6) == 1)
+       if (inet_pton(AF_INET, tmp, &addr) == 1 ||
+           inet_pton(AF_INET6, tmp, &addr6) == 1) {
                return (ISC_FALSE);
+       }
 
        return (ISC_TRUE);
 }
index 2bfd4ae65607975089be44c282ea20125edce4f7..6cb4ce327ad4551cccc818051d21f200f8bde548 100644 (file)
@@ -252,7 +252,7 @@ create_addr(const char *buffer, isc_netaddr_t *addr, int convert_zero) {
        struct in_addr v4;
        struct in6_addr v6;
 
-       if (inet_aton(buffer, &v4) == 1) {
+       if (inet_pton(AF_INET, buffer, &v4) == 1) {
                if (convert_zero) {
                        unsigned char zeroaddress[] = {0, 0, 0, 0};
                        unsigned char loopaddress[] = {127, 0, 0, 1};
index 0c62a99c70565471468608e855c832f330a0c662..30deb48716d1a09a53e7001ebb62d91887705082 100644 (file)
@@ -53,7 +53,7 @@ OBJS =                @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \
                bind9.@O@ buffer.@O@ bufferlist.@O@ \
                commandline.@O@ counter.@O@ crc64.@O@ error.@O@ event.@O@ \
                hash.@O@ ht.@O@ heap.@O@ hex.@O@ hmacmd5.@O@ \
-               hmacsha.@O@ httpd.@O@ inet_aton.@O@ iterated_hash.@O@ \
+               hmacsha.@O@ httpd.@O@ iterated_hash.@O@ \
                lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \
                md5.@O@ mem.@O@ mutexblock.@O@ \
                netaddr.@O@ netscope.@O@ pool.@O@ \
@@ -73,7 +73,7 @@ SRCS =                @ISC_EXTRA_SRCS@ @ISC_PK11_C@ @ISC_PK11_RESULT_C@ \
                aes.c assertions.c backtrace.c base32.c base64.c bind9.c \
                buffer.c bufferlist.c commandline.c counter.c crc64.c \
                error.c event.c hash.c ht.c heap.c hex.c hmacmd5.c \
-               hmacsha.c httpd.c inet_aton.c iterated_hash.c \
+               hmacsha.c httpd.c iterated_hash.c \
                lex.c lfsr.c lib.c log.c \
                md5.c mem.c mutexblock.c \
                netaddr.c netscope.c pool.c \
diff --git a/lib/isc/inet_aton.c b/lib/isc/inet_aton.c
deleted file mode 100644 (file)
index 02d451c..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Portions Copyright (C) 1996-2001, 2004, 2005, 2007, 2008, 2012-2014, 2016-2018  Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*
- * Copyright (c) 1983, 1990, 1993
- *    The Regents of the University of California.  All rights reserved.
- *
- * 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. 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.
- */
-
-/*
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-/*! \file */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_addr.c        8.1 (Berkeley) 6/17/93";
-static char rcsid[] = "$Id: inet_aton.c,v 1.23 2008/12/01 23:47:45 tbox Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <config.h>
-
-#include <ctype.h>
-#include <stddef.h>            /* Required for NULL. */
-
-#include <isc/types.h>
-#include <isc/net.h>
-
-/*%
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-isc_net_aton(const char *cp, struct in_addr *addr) {
-       isc_uint32_t val;
-       int base;
-       ptrdiff_t n;
-       unsigned char c;
-       isc_uint32_t parts[4];
-       isc_uint32_t *pp = parts;
-       int digit;
-
-       c = *cp;
-       for (;;) {
-               /*
-                * Collect number up to ``.''.
-                * Values are specified as for C:
-                * 0x=hex, 0=octal, isdigit=decimal.
-                */
-               if (!isdigit(c & 0xff))
-                       return (0);
-               val = 0; base = 10; digit = 0;
-               if (c == '0') {
-                       c = *++cp;
-                       if (c == 'x' || c == 'X')
-                               base = 16, c = *++cp;
-                       else {
-                               base = 8;
-                               digit = 1;
-                       }
-               }
-               for (;;) {
-                       /*
-                        * isascii() is valid for all integer values, and
-                        * when it is true, c is known to be in scope
-                        * for isdigit().  No cast necessary.  Similar
-                        * comment applies for later ctype uses.
-                        */
-                       if (isascii(c) && isdigit(c)) {
-                               if (base == 8 && (c == '8' || c == '9'))
-                                       return (0);
-                               val = (val * base) + (c - '0');
-                               c = *++cp;
-                               digit = 1;
-                       } else if (base == 16 && isascii(c) && isxdigit(c)) {
-                               val = (val << 4) |
-                                       (c + 10 - (islower(c) ? 'a' : 'A'));
-                               c = *++cp;
-                               digit = 1;
-                       } else
-                               break;
-               }
-               if (c == '.') {
-                       /*
-                        * Internet format:
-                        *      a.b.c.d
-                        *      a.b.c   (with c treated as 16 bits)
-                        *      a.b     (with b treated as 24 bits)
-                        */
-                       if (pp >= parts + 3 || val > 0xffU)
-                               return (0);
-                       *pp++ = val;
-                       c = *++cp;
-               } else
-                       break;
-       }
-       /*
-        * Check for trailing characters.
-        */
-       if (c != '\0' && (!isascii(c) || !isspace(c)))
-               return (0);
-       /*
-        * Did we get a valid digit?
-        */
-       if (!digit)
-               return (0);
-       /*
-        * Concoct the address according to
-        * the number of parts specified.
-        */
-       n = pp - parts + 1;
-       switch (n) {
-       case 1:                         /* a -- 32 bits */
-               break;
-
-       case 2:                         /* a.b -- 8.24 bits */
-               if (val > 0xffffffU)
-                       return (0);
-               val |= parts[0] << 24;
-               break;
-
-       case 3:                         /* a.b.c -- 8.8.16 bits */
-               if (val > 0xffffU)
-                       return (0);
-               val |= (parts[0] << 24) | (parts[1] << 16);
-               break;
-
-       case 4:                         /* a.b.c.d -- 8.8.8.8 bits */
-               if (val > 0xffU)
-                       return (0);
-               val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-               break;
-       }
-       if (addr != NULL)
-               addr->s_addr = htonl(val);
-
-       return (1);
-}
index 3dd792bef06b13e205de35269bb5c3ea783f6a89..211b8af4b96128182e3a340e532c772796ff633b 100644 (file)
@@ -38,7 +38,7 @@
  *
  * It declares ntoh[sl]() and hton[sl]().
  *
- * It declares inet_aton(), inet_ntop(), and inet_pton().
+ * It declares inet_ntop(), and inet_pton().
  *
  * It ensures that #INADDR_LOOPBACK, #INADDR_ANY, #IN6ADDR_ANY_INIT,
  * IN6ADDR_V4MAPPED_INIT, in6addr_any, and in6addr_loopback are available.
@@ -406,11 +406,6 @@ isc_net_pton(int af, const char *src, void *dst);
 #define inet_pton isc_net_pton
 #endif
 
-int
-isc_net_aton(const char *cp, struct in_addr *addr);
-#undef inet_aton
-#define inet_aton isc_net_aton
-
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_NET_H */
index 38f25630fce9a266cfb13eed74c1e6a6f0556c8f..00a38db2dc35873fb0dfd94b7568d92568fe663f 100644 (file)
@@ -34,7 +34,7 @@
  *
  * It declares ntoh[sl]() and hton[sl]().
  *
- * It declares inet_aton(), inet_ntop(), and inet_pton().
+ * It declares inet_ntop(), and inet_pton().
  *
  * It ensures that INADDR_ANY, IN6ADDR_ANY_INIT, in6addr_any, and
  * in6addr_loopback are available.
@@ -410,10 +410,6 @@ isc_net_pton(int af, const char *src, void *dst);
 #define inet_pton isc_net_pton
 #endif
 
-int
-isc_net_aton(const char *cp, struct in_addr *addr);
-#define inet_aton isc_net_aton
-
 ISC_LANG_ENDDECLS
 
 #endif /* ISC_NET_H */
index 44cdd9dd3a208bbfda9814697aa6bdb61b6cb0de..eaf019fd77f8a3ed496e08dad0ea4c757c901731 100644 (file)
     <ClCompile Include="..\httpd.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\inet_aton.c">
-      <Filter>Library Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\inet_ntop.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
index c1125b493b4ab1ec1da5ee4cace287c66bb06da7..0815eac2e87ca34f302e0aae42f20435b0d580b9 100644 (file)
@@ -447,7 +447,6 @@ copy InstallFiles ..\Build\Release\
     <ClCompile Include="..\hmacsha.c" />
     <ClCompile Include="..\ht.c" />
     <ClCompile Include="..\httpd.c" />
-    <ClCompile Include="..\inet_aton.c" />
     <ClCompile Include="..\inet_ntop.c" />
     <ClCompile Include="..\inet_pton.c" />
     <ClCompile Include="..\iterated_hash.c" />
index 05bf794cf1b44bb03adba95dc099bddb9753cde6..8ad98a1c724b838fcf6c986080012a8f00a8d8c4 100644 (file)
@@ -1741,7 +1741,7 @@ check_mx(ns_client_t *client, dns_zone_t *zone,
                    strlcpy(tmp, namebuf, sizeof(tmp)) < sizeof(tmp)) {
                        if (tmp[strlen(tmp) - 1] == '.')
                                tmp[strlen(tmp) - 1] = '\0';
-                       if (inet_aton(tmp, &addr) == 1 ||
+                       if (inet_pton(AF_INET, tmp, &addr) == 1 ||
                            inet_pton(AF_INET6, tmp, &addr6) == 1)
                                isaddress = ISC_TRUE;
                }
index 4ad85285f73903495219650d241a1b1699f1fcad..b661ea523972144593e8bd35dae606cc92edc83b 100644 (file)
 ./lib/isc/include/pkcs11/pkcs11.h              X       2014,2016,2018
 ./lib/isc/include/pkcs11/pkcs11f.h             X       2014,2016,2018
 ./lib/isc/include/pkcs11/pkcs11t.h             X       2014,2016,2018
-./lib/isc/inet_aton.c                          C.PORTION       1996,1997,1998,1999,2000,2001,2004,2005,2007,2008,2012,2013,2014,2016,2017,2018
 ./lib/isc/inet_ntop.c                          C       1996,1997,1998,1999,2000,2001,2004,2005,2007,2009,2016,2017,2018
 ./lib/isc/inet_pton.c                          C       1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2007,2013,2014,2016,2017,2018
 ./lib/isc/iterated_hash.c                      C       2006,2008,2009,2016,2018