]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Move VA_COPY macro into compat header.
authorDarren Tucker <dtucker@zip.com.au>
Fri, 15 Jul 2016 04:48:30 +0000 (14:48 +1000)
committerDarren Tucker <dtucker@zip.com.au>
Fri, 15 Jul 2016 04:54:16 +0000 (14:54 +1000)
Some AIX compilers unconditionally undefine va_copy but don't set it back
to an internal function, causing link errors.  In some compat code we
already use VA_COPY instead so move the two existing instances into the
shared header and use for sshbuf-getput-basic.c too.  Should fix building
with at lease some versions of AIX's compiler.  bz#2589, ok djm@

openbsd-compat/bsd-asprintf.c
openbsd-compat/bsd-snprintf.c
openbsd-compat/openbsd-compat.h
sshbuf-getput-basic.c

index 3368195d443ae1a8470528ecf0211ccdfba17847..7b83448ca2cdff157bed9bda762bfd8d13b334ba 100644 (file)
 #include <stdarg.h>
 #include <stdlib.h>
 
-#ifndef VA_COPY
-# ifdef HAVE_VA_COPY
-#  define VA_COPY(dest, src) va_copy(dest, src)
-# else
-#  ifdef HAVE___VA_COPY
-#   define VA_COPY(dest, src) __va_copy(dest, src)
-#  else
-#   define VA_COPY(dest, src) (dest) = (src)
-#  endif
-# endif
-#endif
-
 #define INIT_SZ        128
 
 int
index 23a6359898e8f9bd38c28454268cc54c1049e9ee..d95b6a40158f0f29735946de96f62924e8c8e87b 100644 (file)
 # undef HAVE_VSNPRINTF
 #endif
 
-#ifndef VA_COPY
-# ifdef HAVE_VA_COPY
-#  define VA_COPY(dest, src) va_copy(dest, src)
-# else
-#  ifdef HAVE___VA_COPY
-#   define VA_COPY(dest, src) __va_copy(dest, src)
-#  else
-#   define VA_COPY(dest, src) (dest) = (src)
-#  endif
-# endif
-#endif
-
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
 
 #include <ctype.h>
index 997541e437440462b19dc3a362bc9a6c9635bcaa..37d2064cd9ea87a4f8797cd813c29fe12b20a8eb 100644 (file)
@@ -253,6 +253,23 @@ int mbtowc(wchar_t *, const char*, size_t);
 # include <stdarg.h>
 #endif
 
+/*
+ * Some platforms unconditionally undefine va_copy() so we define VA_COPY()
+ * instead.  This is known to be the case on at least some configurations of
+ * AIX with the xlc compiler.
+ */
+#ifndef VA_COPY
+# ifdef HAVE_VA_COPY
+#  define VA_COPY(dest, src) va_copy(dest, src)
+# else
+#  ifdef HAVE___VA_COPY
+#   define VA_COPY(dest, src) __va_copy(dest, src)
+#  else
+#   define VA_COPY(dest, src) (dest) = (src)
+#  endif
+# endif
+#endif
+
 #ifndef HAVE_VASPRINTF
 int vasprintf(char **, const char *, va_list);
 #endif
index ad21ae574ce663f3cf160c1e09a09b70cbea2dff..74c49be7cc62d699fcdd39f486bac3d4cff58adb 100644 (file)
@@ -270,7 +270,7 @@ sshbuf_putfv(struct sshbuf *buf, const char *fmt, va_list ap)
        int r, len;
        u_char *p;
 
-       va_copy(ap2, ap);
+       VA_COPY(ap2, ap);
        if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) {
                r = SSH_ERR_INVALID_ARGUMENT;
                goto out;
@@ -280,7 +280,7 @@ sshbuf_putfv(struct sshbuf *buf, const char *fmt, va_list ap)
                goto out; /* Nothing to do */
        }
        va_end(ap2);
-       va_copy(ap2, ap);
+       VA_COPY(ap2, ap);
        if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0)
                goto out;
        if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) {