summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2019-02-06 20:35:11 +0100
committerTim Rühsen <tim.ruehsen@gmx.de>2019-02-07 10:34:22 +0100
commitdb5ac39e61fe1fc20bf3f69f603516803631cbeb (patch)
treea52b2fa219a5484bc315e10c4fd3638ce1fc67d7
parent71afdf09b820180f3125eeefaeb787155e7333fc (diff)
downloadgnutls-tmp-gnulib-ntop.tar.gz
Use inet_ntop() from gnulibtmp-gnulib-ntop
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rw-r--r--bootstrap.conf2
-rw-r--r--configure.ac2
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/system.h7
-rw-r--r--lib/system/inet_ntop.c250
-rw-r--r--lib/x509/ip.c5
6 files changed, 4 insertions, 264 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index 672c4b1ba3..31f054bc0e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -29,7 +29,7 @@ required_submodules="tests/suite/tls-fuzzer/python-ecdsa tests/suite/tls-fuzzer/
# Reproduce by: gnulib-tool --import --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files alloca byteswap c-ctype extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r unistd vasprintf vsnprintf warnings
gnulib_modules="
-alloca byteswap c-ctype c-strcase extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strdup-posix strndup strtok_r strverscmp sys_socket sys_stat sys_types time_r unistd valgrind-tests vasprintf vsnprintf warnings
+alloca byteswap c-ctype c-strcase extensions func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib inet_ntop intprops lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strdup-posix strndup strtok_r strverscmp sys_socket sys_stat sys_types time_r unistd valgrind-tests vasprintf vsnprintf warnings
"
unistring_modules="
diff --git a/configure.ac b/configure.ac
index b740bad029..f0d18635cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,7 +301,7 @@ AC_C_BIGENDIAN
dnl No fork on MinGW, disable some self-tests until we fix them.
dnl Check clock_gettime and pthread_mutex_lock in libc (avoid linking to other libs)
-AC_CHECK_FUNCS([fork setitimer inet_ntop inet_pton getrusage getpwuid_r nanosleep daemon getpid localtime mmap explicit_bzero],,)
+AC_CHECK_FUNCS([fork setitimer inet_pton getrusage getpwuid_r nanosleep daemon getpid localtime mmap explicit_bzero],,)
dnl Manually check some functions by including headers first. On macOS, you
dnl normally only have the latest SDK available, containing all existing
dnl functions, but having them restricted according to target version in
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9f140469da..d29e415720 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -72,7 +72,7 @@ COBJECTS = range.c record.c compress.c debug.c cipher.c gthreads.h handshake-tls
pk.c cert-cred.c global.c constate.c anon_cred.c pkix_asn1_tab.c gnutls_asn1_tab.c \
mem.c fingerprint.c tls-sig.c ecc.c alert.c privkey_raw.c atomic.h \
system/certs.c system/threads.c system/fastopen.c system/sockets.c \
- system/inet_ntop.c str-iconv.c system.c \
+ str-iconv.c system.c \
str.c str-unicode.c str-idna.c state.c cert-cred-x509.c file.c supplemental.c \
random.c crypto-api.c crypto-api.h privkey.c pcert.c pubkey.c locks.c dtls.c \
system_override.c crypto-backend.c verify-tofu.c pin.c tpm.c fips.c \
diff --git a/lib/system.h b/lib/system.h
index 6a948f858d..18c2603bec 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -124,11 +124,4 @@ int inet_aton(const char *cp, struct in_addr *inp);
int inet_pton(int af, const char *src, void *dst);
#endif
-#ifndef HAVE_INET_NTOP
-# undef inet_ntop
-# define inet_ntop _gnutls_inet_ntop
-const char *inet_ntop(int af, const void *src,
- char *dst, unsigned size);
-#endif
-
#endif /* SYSTEM_H */
diff --git a/lib/system/inet_ntop.c b/lib/system/inet_ntop.c
deleted file mode 100644
index 87760ebf11..0000000000
--- a/lib/system/inet_ntop.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
-
- Copyright (C) 2005-2006, 2008-2015 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
-
-/*
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM 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.
- */
-
-#include <config.h>
-
-#ifndef HAVE_INET_NTOP
-
-# include <stdio.h>
-# include <string.h>
-# include <errno.h>
-# include <sys/socket.h>
-# include "system.h"
-
-# ifndef IF_LINT
-# define IF_LINT
-#endif
-
-# ifndef HAVE_IPV6
-# define HAVE_IPV6 1
-# endif
-
-# ifndef HAVE_IPV4
-# define HAVE_IPV4 1
-# endif
-
-# define NS_IN6ADDRSZ 16
-# define NS_INT16SZ 2
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
-
-static const char *inet_ntop4 (const unsigned char *src, char *dst, unsigned size);
-# if HAVE_IPV6
-static const char *inet_ntop6 (const unsigned char *src, char *dst, unsigned size);
-# endif
-
-
-/* char *
- * inet_ntop(af, src, dst, size)
- * convert a network format address to presentation format.
- * return:
- * pointer to presentation format address ('dst'), or NULL (see errno).
- * author:
- * Paul Vixie, 1996.
- */
-const char *
-inet_ntop (int af, const void *restrict src,
- char *restrict dst, unsigned cnt)
-{
- switch (af)
- {
-# if HAVE_IPV4
- case AF_INET:
- return (inet_ntop4 (src, dst, cnt));
-# endif
-
-# if HAVE_IPV6
- case AF_INET6:
- return (inet_ntop6 (src, dst, cnt));
-# endif
-
- default:
- errno = EAFNOSUPPORT;
- return (NULL);
- }
- /* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- * format an IPv4 address
- * return:
- * 'dst' (as a const)
- * notes:
- * (1) uses no statics
- * (2) takes a u_char* not an in_addr as input
- * author:
- * Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4 (const unsigned char *src, char *dst, unsigned size)
-{
- char tmp[sizeof "255.255.255.255"];
- int len;
-
- len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
- if (len < 0)
- return NULL;
-
- if ((unsigned)len > size)
- {
- errno = ENOSPC;
- return NULL;
- }
-
- return strcpy (dst, tmp);
-}
-
-# if HAVE_IPV6
-
-/* const char *
- * inet_ntop6(src, dst, size)
- * convert IPv6 binary address into presentation (printable) format
- * author:
- * Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6 (const unsigned char *src, char *dst, unsigned size)
-{
- /*
- * Note that int32_t and int16_t need only be "at least" large enough
- * to contain a value of the specified size. On some systems, like
- * Crays, there is no such thing as an integer variable with 16 bits.
- * Keep this in mind if you think this function should have been coded
- * to use pointer overlays. All the world's not a VAX.
- */
- char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
- struct
- {
- int base, len;
- } best, cur;
- unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
- int i;
-
- /*
- * Preprocess:
- * Copy the input (bytewise) array into a wordwise array.
- * Find the longest run of 0x00's in src[] for :: shorthanding.
- */
- memset (words, '\0', sizeof words);
- for (i = 0; i < NS_IN6ADDRSZ; i += 2)
- words[i / 2] = (src[i] << 8) | src[i + 1];
- best.base = -1;
- cur.base = -1;
- IF_LINT(best.len = 0);
- IF_LINT(cur.len = 0);
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
- {
- if (words[i] == 0)
- {
- if (cur.base == -1)
- cur.base = i, cur.len = 1;
- else
- cur.len++;
- }
- else
- {
- if (cur.base != -1)
- {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- cur.base = -1;
- }
- }
- }
- if (cur.base != -1)
- {
- if (best.base == -1 || cur.len > best.len)
- best = cur;
- }
- if (best.base != -1 && best.len < 2)
- best.base = -1;
-
- /*
- * Format the result.
- */
- tp = tmp;
- for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
- {
- /* Are we inside the best run of 0x00's? */
- if (best.base != -1 && i >= best.base && i < (best.base + best.len))
- {
- if (i == best.base)
- *tp++ = ':';
- continue;
- }
- /* Are we following an initial run of 0x00s or any real hex? */
- if (i != 0)
- *tp++ = ':';
- /* Is this address an encapsulated IPv4? */
- if (i == 6 && best.base == 0 &&
- (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
- {
- if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
- tp += strlen (tp);
- break;
- }
- {
- int len = sprintf (tp, "%x", words[i]);
- if (len < 0)
- return NULL;
- tp += len;
- }
- }
- /* Was it a trailing run of 0x00's? */
- if (best.base != -1 && (best.base + best.len) ==
- (NS_IN6ADDRSZ / NS_INT16SZ))
- *tp++ = ':';
- *tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
- if ((unsigned) (tp - tmp) > size)
- {
- errno = ENOSPC;
- return NULL;
- }
-
- return strcpy (dst, tmp);
-}
-
-# endif
-
-#endif
diff --git a/lib/x509/ip.c b/lib/x509/ip.c
index b4b31a4f94..644d2f58f5 100644
--- a/lib/x509/ip.c
+++ b/lib/x509/ip.c
@@ -24,10 +24,7 @@
#include "gnutls_int.h"
#include "ip.h"
#include <gnutls/x509.h>
-
-#ifdef HAVE_INET_NTOP
-# include <arpa/inet.h>
-#endif
+#include <arpa/inet.h>
/*-
* _gnutls_mask_to_prefix: