summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2018-12-19 09:41:41 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-12-19 11:08:59 +0100
commit5b0ff19b08979f0c4d60cafcd23fcad8d61c3cc4 (patch)
treee165038ccb8c93d6d648d05f1c3ff762f172e390
parent62f162f64c23a5e6b872ff8ee540d375b7e27168 (diff)
downloadgnutls-5b0ff19b08979f0c4d60cafcd23fcad8d61c3cc4.tar.gz
vasprintf: use from gnulib; don't bundle twice
Relates #653 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--configure.ac24
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/errors.c1
-rw-r--r--lib/str.c1
-rw-r--r--lib/system/vasprintf.c84
-rw-r--r--lib/vasprintf.h12
6 files changed, 2 insertions, 122 deletions
diff --git a/configure.ac b/configure.ac
index 21ab6bbe9d..2530a805c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,7 +293,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 vasprintf mmap explicit_bzero],,)
+AC_CHECK_FUNCS([fork setitimer inet_ntop 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
@@ -311,28 +311,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [fmemopen(0, 0, 0);])],
[AC_MSG_RESULT(yes); ac_cv_func_fmemopen=yes
AC_DEFINE([HAVE_FMEMOPEN], 1, [Define to 1 if you have the `fmemopen' function.])],
[AC_MSG_RESULT(no); ac_cv_func_fmemopen=no])
-if test "$ac_cv_func_vasprintf" != "yes";then
- AC_MSG_CHECKING([for va_copy])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([
- #include <stdarg.h>
- va_list a;],[
- va_list b;
- va_copy(b,a);
- va_end(b);])],
- [AC_DEFINE([HAVE_VA_COPY], 1, [Have va_copy()])
- AC_MSG_RESULT(va_copy)],
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([
- #include <stdarg.h>
- va_list a;],[
- va_list b;
- __va_copy(b,a);
- va_end(b);])],
- [AC_DEFINE([HAVE___VA_COPY], 1, [Have __va_copy()])
- AC_MSG_RESULT(__va_copy)],
- [AC_MSG_RESULT(no)
- AC_MSG_ERROR([Your system lacks vasprintf() and va_copy()])])
- ])
-fi
AM_CONDITIONAL(HAVE_FORK, test "$ac_cv_func_fork" != "no")
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e7c5c7f40e..5c0eac680c 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/vasprintf.c vasprintf.h system.c \
+ system/inet_ntop.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/errors.c b/lib/errors.c
index acdaf65bca..a1bdf9b873 100644
--- a/lib/errors.c
+++ b/lib/errors.c
@@ -26,7 +26,6 @@
#ifdef STDC_HEADERS
#include <stdarg.h>
#endif
-#include "vasprintf.h"
#include "str.h"
#define ERROR_ENTRY(desc, name) \
diff --git a/lib/str.c b/lib/str.c
index c8d742e91e..f766915bc0 100644
--- a/lib/str.c
+++ b/lib/str.c
@@ -29,7 +29,6 @@
#include <c-ctype.h>
#include <intprops.h>
#include <nettle/base64.h>
-#include "vasprintf.h"
#include "extras/hex.h"
/* These functions are like strcat, strcpy. They only
diff --git a/lib/system/vasprintf.c b/lib/system/vasprintf.c
deleted file mode 100644
index 8362942a20..0000000000
--- a/lib/system/vasprintf.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright © 2008-2014 Intel Corporation.
- *
- * Authors: David Woodhouse <dwmw2@infradead.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1, as published by the Free Software Foundation.
- *
- * 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
- * Lesser General Public License for more details.
- */
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdarg.h>
-#include "vasprintf.h"
-
-#ifndef HAVE_VASPRINTF
-
-int _gnutls_vasprintf(char **strp, const char *fmt, va_list ap)
-{
- va_list ap2;
- char *res = NULL;
- int len = 160, len2;
- int ret = 0;
- int errno_save = -ENOMEM;
-
- res = malloc(160);
- if (!res)
- goto err;
-
- /* Use a copy of 'ap', preserving it in case we need to retry into
- a larger buffer. 160 characters should be sufficient for most
- strings in openconnect. */
-#ifdef HAVE_VA_COPY
- va_copy(ap2, ap);
-#elif defined(HAVE___VA_COPY)
- __va_copy(ap2, ap);
-#else
-#error No va_copy()!
- /* You could try this. */
- ap2 = ap;
- /* Or this */
- *ap2 = *ap;
-#endif
- len = vsnprintf(res, 160, fmt, ap2);
- va_end(ap2);
-
- if (len < 0) {
- printf_err:
- errno_save = errno;
- free(res);
- res = NULL;
- goto err;
- }
- if (len >= 0 && len < 160)
- goto out;
-
- free(res);
- res = malloc(len+1);
- if (!res)
- goto err;
-
- len2 = vsnprintf(res, len+1, fmt, ap);
- if (len2 < 0 || len2 > len)
- goto printf_err;
-
- ret = 0;
- goto out;
-
- err:
- errno = errno_save;
- ret = -1;
- out:
- *strp = res;
- return ret;
-}
-
-#endif
diff --git a/lib/vasprintf.h b/lib/vasprintf.h
deleted file mode 100644
index 70574806bc..0000000000
--- a/lib/vasprintf.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef VASPRINTF_H
-#define VASPRINTF_H
-#include <config.h>
-
-#ifndef HAVE_VASPRINTF
-
-int _gnutls_vasprintf(char **strp, const char *fmt, va_list ap);
-#define vasprintf _gnutls_vasprintf
-
-#endif
-
-#endif