diff --git a/config.h.in b/config.h.in index 678ebd0c6..90be6906b 100644 --- a/config.h.in +++ b/config.h.in @@ -967,6 +967,9 @@ /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF +/* Define to 1 if you have the `va_copy' function. */ +#undef HAVE_VA_COPY + /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF @@ -1018,6 +1021,9 @@ /* Define to 1 if your crt0.o defines the __progname symbol for you. */ #undef HAVE___PROGNAME +/* Define to 1 if you have the `__va_copy' function. */ +#undef HAVE___VA_COPY + /* Define to 1 if you want the hostname to be entered into the log file. */ #undef HOST_IN_LOG diff --git a/configure b/configure index 168cbfa72..d5275c6f3 100755 --- a/configure +++ b/configure @@ -23316,6 +23316,78 @@ fi esac LIBS="$OLIBS" +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5 +printf %s "checking for va_copy... " >&6; } +if test ${sudo_cv_func_va_copy+y} +then : + printf %s "(cached) " >&6 +else $as_nop + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + va_list ap1, ap2; +int +main (void) +{ +va_copy(ap1, ap2); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + sudo_cv_func_va_copy=yes +else $as_nop + sudo_cv_func_va_copy=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_func_va_copy" >&5 +printf "%s\n" "$sudo_cv_func_va_copy" >&6; } +if test "$sudo_cv_func_va_copy" = "yes"; then + printf "%s\n" "#define HAVE_VA_COPY 1" >>confdefs.h + +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __va_copy" >&5 +printf %s "checking for __va_copy... " >&6; } +if test ${sudo_cv_func___va_copy+y} +then : + printf %s "(cached) " >&6 +else $as_nop + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + va_list ap1, ap2; +int +main (void) +{ +__va_copy(ap1, ap2); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + sudo_cv_func___va_copy=yes +else $as_nop + sudo_cv_func___va_copy=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_func___va_copy" >&5 +printf "%s\n" "$sudo_cv_func___va_copy" >&6; } + if test "$sudo_cv_func___va_copy" = "yes"; then + printf "%s\n" "#define HAVE___VA_COPY 1" >>confdefs.h + + fi +fi + for ac_func in getprogname do : @@ -31782,6 +31854,8 @@ fi + + diff --git a/configure.ac b/configure.ac index ea405644a..d1cf9ebbe 100644 --- a/configure.ac +++ b/configure.ac @@ -3226,6 +3226,27 @@ case " $LIBOBJS " in esac LIBS="$OLIBS" +dnl +dnl Check for va_copy or __va_copy in stdarg.h +dnl +AC_CACHE_CHECK([for va_copy], sudo_cv_func_va_copy, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include + va_list ap1, ap2;]], [[va_copy(ap1, ap2);]])], + [sudo_cv_func_va_copy=yes], [sudo_cv_func_va_copy=no]) +]) +if test "$sudo_cv_func_va_copy" = "yes"; then + AC_DEFINE(HAVE_VA_COPY) +else + AC_CACHE_CHECK([for __va_copy], sudo_cv_func___va_copy, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include + va_list ap1, ap2;]], [[__va_copy(ap1, ap2);]])], + [sudo_cv_func___va_copy=yes], [sudo_cv_func___va_copy=no]) + ]) + if test "$sudo_cv_func___va_copy" = "yes"; then + AC_DEFINE(HAVE___VA_COPY) + fi +fi + dnl dnl Check for getprogname()/setprogname() or __progname dnl @@ -5128,6 +5149,8 @@ AH_TEMPLATE(HAVE_SSL_CTX_SET_MIN_PROTO_VERSION, [Define to 1 if you have the `SS AH_TEMPLATE(HAVE_SSL_CTX_SET_CIPHERSUITES, [Define to 1 if you have the `SSL_CTX_set_ciphersuites' function or macro.]) AH_TEMPLATE(SUDOERS_LOG_CLIENT, [Define to 1 to compile support for sudo_logsrvd in the sudoers plugin.]) AH_TEMPLATE(HAVE_FALLTHROUGH_ATTRIBUTE, [Define to 1 if the compiler supports the fallthrough attribute.]) +AH_TEMPLATE(HAVE_VA_COPY, [Define to 1 if you have the `va_copy' function.]) +AH_TEMPLATE(HAVE___VA_COPY, [Define to 1 if you have the `__va_copy' function.]) dnl dnl Bits to copy verbatim into config.h.in diff --git a/include/sudo_compat.h b/include/sudo_compat.h index 6bc74a99d..971443dd9 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -91,8 +91,8 @@ /* * Pre-C99 compilers may lack a va_copy macro. */ -#ifndef va_copy -# ifdef __va_copy +#ifndef HAVE_VA_COPY +# ifdef HAVE___VA_COPY # define va_copy(d, s) __va_copy(d, s) # else # define va_copy(d, s) memcpy(&(d), &(s), sizeof(d));