From 57a5a0095c3fe0f22dcbb9d99a82cc94f2b608c7 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Sun, 17 Jan 2016 14:30:53 -0800 Subject: Update to rra-c-util 5.10 and C TAP Harness 3.4 Update to rra-c-util 5.10: * Add missing va_end to xasprintf implementation. * Fix Perl test suite framework for new Automake relative paths. * Improve portability to Kerberos included in Solaris 10. * Use appropriate warning flags with Clang (currently not warning clean). Update to C TAP Harness 3.4: * Fix segfault in runtests with an empty test list. * Display verbose test results with -v or C_TAP_VERBOSE. * Test infrastructure builds cleanly with Clang warnings. * Support comments and blank lines in test lists. --- portable/asprintf.c | 6 +++++- portable/krb5-extra.c | 3 +++ portable/krb5.h | 4 +++- portable/macros.h | 3 ++- portable/mkstemp.c | 5 ++++- portable/reallocarray.c | 8 ++++---- portable/setenv.c | 24 +++++++++--------------- portable/snprintf.c | 2 ++ portable/strlcat.c | 1 + portable/strlcpy.c | 1 + portable/system.h | 4 ++-- 11 files changed, 36 insertions(+), 25 deletions(-) (limited to 'portable') diff --git a/portable/asprintf.c b/portable/asprintf.c index eb2b713..9693842 100644 --- a/portable/asprintf.c +++ b/portable/asprintf.c @@ -19,6 +19,7 @@ */ #include +#include #include #include @@ -28,11 +29,14 @@ * with the system versions. */ #if TESTING +# undef asprintf +# undef vasprintf # define asprintf test_asprintf # define vasprintf test_vasprintf int test_asprintf(char **, const char *, ...) __attribute__((__format__(printf, 2, 3))); -int test_vasprintf(char **, const char *, va_list); +int test_vasprintf(char **, const char *, va_list) + __attribute__((__format__(printf, 2, 0))); #endif diff --git a/portable/krb5-extra.c b/portable/krb5-extra.c index b1c8b8d..c8309a4 100644 --- a/portable/krb5-extra.c +++ b/portable/krb5-extra.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -33,6 +34,8 @@ # include # elif defined(HAVE_ET_COM_ERR_H) # include +# elif defined(HAVE_KERBEROSV5_COM_ERR_H) +# include # else # include # endif diff --git a/portable/krb5.h b/portable/krb5.h index 6dfffd5..34f960e 100644 --- a/portable/krb5.h +++ b/portable/krb5.h @@ -42,8 +42,10 @@ #endif #include -#ifdef HAVE_KRB5_H +#if defined(HAVE_KRB5_H) # include +#elif defined(HAVE_KERBEROSV5_KRB5_H) +# include #else # include #endif diff --git a/portable/macros.h b/portable/macros.h index b5093f5..d4cc2cc 100644 --- a/portable/macros.h +++ b/portable/macros.h @@ -37,7 +37,8 @@ * variadic macro support. */ #if !defined(__attribute__) && !defined(__alloc_size__) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) +# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) \ + && !defined(__clang__) # define __alloc_size__(spec, args...) /* empty */ # endif #endif diff --git a/portable/mkstemp.c b/portable/mkstemp.c index 2cbfe08..7c733a4 100644 --- a/portable/mkstemp.c +++ b/portable/mkstemp.c @@ -23,7 +23,10 @@ #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif +#include /* * If we're running the test suite, rename mkstemp to avoid conflicts with the diff --git a/portable/reallocarray.c b/portable/reallocarray.c index 7d40a7a..e9404e9 100644 --- a/portable/reallocarray.c +++ b/portable/reallocarray.c @@ -1,10 +1,10 @@ /* * Replacement for a missing reallocarray. * - * Provides the same functionality as the OpenBSD library function reallocrray - * for those systems that don't have it. This function is the same as - * realloc, but takes the size arguments in the same form as calloc and checks - * for overflow so that the caller doesn't need to. + * Provides the same functionality as the OpenBSD library function + * reallocarray for those systems that don't have it. This function is the + * same as realloc, but takes the size arguments in the same form as calloc + * and checks for overflow so that the caller doesn't need to. * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . diff --git a/portable/setenv.c b/portable/setenv.c index 472282a..f1f6db4 100644 --- a/portable/setenv.c +++ b/portable/setenv.c @@ -26,6 +26,7 @@ * the system version. */ #if TESTING +# undef setenv # define setenv test_setenv int test_setenv(const char *, const char *, int); #endif @@ -34,29 +35,22 @@ int setenv(const char *name, const char *value, int overwrite) { char *envstring; - size_t size; + /* Do nothing if not overwriting and the variable is already set. */ if (!overwrite && getenv(name) != NULL) return 0; - /* - * Allocate memory for the environment string. We intentionally don't use - * the xmalloc family of allocation routines here, since the intention is - * to provide a replacement for the standard library function that sets - * errno and returns in the event of a memory allocation failure. - */ - size = strlen(name) + 1 + strlen(value) + 1; - envstring = malloc(size); - if (envstring == NULL) - return -1; - /* * Build the environment string and add it to the environment using * putenv. Systems without putenv lose, but XPG4 requires it. + * + * We intentionally don't use the xmalloc family of allocation routines + * here, since the intention is to provide a replacement for the standard + * library function that sets errno and returns in the event of a memory + * allocation failure. */ - strlcpy(envstring, name, size); - strlcat(envstring, "=", size); - strlcat(envstring, value, size); + if (asprintf(&envstring, "%s=%s", name, value) < 0) + return -1; return putenv(envstring); /* diff --git a/portable/snprintf.c b/portable/snprintf.c index c35ad80..9818acd 100644 --- a/portable/snprintf.c +++ b/portable/snprintf.c @@ -19,6 +19,8 @@ * conflicts with the system version. */ #if TESTING +# undef snprintf +# undef vsnprintf # define snprintf test_snprintf # define vsnprintf test_vsnprintf #endif diff --git a/portable/strlcat.c b/portable/strlcat.c index 9c8686d..613d3f2 100644 --- a/portable/strlcat.c +++ b/portable/strlcat.c @@ -31,6 +31,7 @@ * the system version. */ #if TESTING +# undef strlcat # define strlcat test_strlcat size_t test_strlcat(char *, const char *, size_t); #endif diff --git a/portable/strlcpy.c b/portable/strlcpy.c index 592e3ee..60fdab3 100644 --- a/portable/strlcpy.c +++ b/portable/strlcpy.c @@ -30,6 +30,7 @@ * the system version. */ #if TESTING +# undef strlcpy # define strlcpy test_strlcpy size_t test_strlcpy(char *, const char *, size_t); #endif diff --git a/portable/system.h b/portable/system.h index 544b2de..581e46c 100644 --- a/portable/system.h +++ b/portable/system.h @@ -136,10 +136,10 @@ extern void *reallocarray(void *, size_t, size_t); #if !HAVE_SETENV extern int setenv(const char *, const char *, int); #endif -#if !HAVE_STRLCAT +#if !HAVE_DECL_STRLCAT extern size_t strlcat(char *, const char *, size_t); #endif -#if !HAVE_STRLCPY +#if !HAVE_DECL_STRLCPY extern size_t strlcpy(char *, const char *, size_t); #endif -- cgit v1.2.3