diff options
-rw-r--r-- | openbsd-compat/bsd-asprintf.c | 12 | ||||
-rw-r--r-- | openbsd-compat/bsd-snprintf.c | 12 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 17 | ||||
-rw-r--r-- | sshbuf-getput-basic.c | 4 |
4 files changed, 19 insertions, 26 deletions
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c index 3368195d4..7b83448ca 100644 --- a/openbsd-compat/bsd-asprintf.c +++ b/openbsd-compat/bsd-asprintf.c | |||
@@ -25,18 +25,6 @@ | |||
25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | 27 | ||
28 | #ifndef VA_COPY | ||
29 | # ifdef HAVE_VA_COPY | ||
30 | # define VA_COPY(dest, src) va_copy(dest, src) | ||
31 | # else | ||
32 | # ifdef HAVE___VA_COPY | ||
33 | # define VA_COPY(dest, src) __va_copy(dest, src) | ||
34 | # else | ||
35 | # define VA_COPY(dest, src) (dest) = (src) | ||
36 | # endif | ||
37 | # endif | ||
38 | #endif | ||
39 | |||
40 | #define INIT_SZ 128 | 28 | #define INIT_SZ 128 |
41 | 29 | ||
42 | int | 30 | int |
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c index 23a635989..d95b6a401 100644 --- a/openbsd-compat/bsd-snprintf.c +++ b/openbsd-compat/bsd-snprintf.c | |||
@@ -99,18 +99,6 @@ | |||
99 | # undef HAVE_VSNPRINTF | 99 | # undef HAVE_VSNPRINTF |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #ifndef VA_COPY | ||
103 | # ifdef HAVE_VA_COPY | ||
104 | # define VA_COPY(dest, src) va_copy(dest, src) | ||
105 | # else | ||
106 | # ifdef HAVE___VA_COPY | ||
107 | # define VA_COPY(dest, src) __va_copy(dest, src) | ||
108 | # else | ||
109 | # define VA_COPY(dest, src) (dest) = (src) | ||
110 | # endif | ||
111 | # endif | ||
112 | #endif | ||
113 | |||
114 | #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) | 102 | #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) |
115 | 103 | ||
116 | #include <ctype.h> | 104 | #include <ctype.h> |
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 997541e43..37d2064cd 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -253,6 +253,23 @@ int mbtowc(wchar_t *, const char*, size_t); | |||
253 | # include <stdarg.h> | 253 | # include <stdarg.h> |
254 | #endif | 254 | #endif |
255 | 255 | ||
256 | /* | ||
257 | * Some platforms unconditionally undefine va_copy() so we define VA_COPY() | ||
258 | * instead. This is known to be the case on at least some configurations of | ||
259 | * AIX with the xlc compiler. | ||
260 | */ | ||
261 | #ifndef VA_COPY | ||
262 | # ifdef HAVE_VA_COPY | ||
263 | # define VA_COPY(dest, src) va_copy(dest, src) | ||
264 | # else | ||
265 | # ifdef HAVE___VA_COPY | ||
266 | # define VA_COPY(dest, src) __va_copy(dest, src) | ||
267 | # else | ||
268 | # define VA_COPY(dest, src) (dest) = (src) | ||
269 | # endif | ||
270 | # endif | ||
271 | #endif | ||
272 | |||
256 | #ifndef HAVE_VASPRINTF | 273 | #ifndef HAVE_VASPRINTF |
257 | int vasprintf(char **, const char *, va_list); | 274 | int vasprintf(char **, const char *, va_list); |
258 | #endif | 275 | #endif |
diff --git a/sshbuf-getput-basic.c b/sshbuf-getput-basic.c index ad21ae574..74c49be7c 100644 --- a/sshbuf-getput-basic.c +++ b/sshbuf-getput-basic.c | |||
@@ -270,7 +270,7 @@ sshbuf_putfv(struct sshbuf *buf, const char *fmt, va_list ap) | |||
270 | int r, len; | 270 | int r, len; |
271 | u_char *p; | 271 | u_char *p; |
272 | 272 | ||
273 | va_copy(ap2, ap); | 273 | VA_COPY(ap2, ap); |
274 | if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) { | 274 | if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) { |
275 | r = SSH_ERR_INVALID_ARGUMENT; | 275 | r = SSH_ERR_INVALID_ARGUMENT; |
276 | goto out; | 276 | goto out; |
@@ -280,7 +280,7 @@ sshbuf_putfv(struct sshbuf *buf, const char *fmt, va_list ap) | |||
280 | goto out; /* Nothing to do */ | 280 | goto out; /* Nothing to do */ |
281 | } | 281 | } |
282 | va_end(ap2); | 282 | va_end(ap2); |
283 | va_copy(ap2, ap); | 283 | VA_COPY(ap2, ap); |
284 | if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0) | 284 | if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0) |
285 | goto out; | 285 | goto out; |
286 | if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) { | 286 | if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) { |