summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-asprintf.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-21 00:00:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-08-21 00:00:13 +0000
commited358b3546c776c1c677fd88eb8f716cf6187510 (patch)
tree3c6134bcb2cda4b9dccc57b4a8b997a945aab62d /openbsd-compat/bsd-asprintf.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parent44a1065de8a58c51a021243a28bfa01e87822e4f (diff)
Merge changes I934c73d4,I28cdc9a0,I9e734da9,I3c079d86
* changes: UPSTREAM: depend UPSTREAM: upstream: avoid possible NULL deref; from Pedro Martelletto Revert "upstream: fix compilation with DEBUG_KEXDH; bz#3160 ok dtucker@" Merge upstream-master into master
Diffstat (limited to 'openbsd-compat/bsd-asprintf.c')
-rw-r--r--openbsd-compat/bsd-asprintf.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c
index 3368195d..10927727 100644
--- a/openbsd-compat/bsd-asprintf.c
+++ b/openbsd-compat/bsd-asprintf.c
@@ -19,24 +19,21 @@
#include "includes.h"
+/*
+ * Don't let systems with broken printf(3) avoid our replacements
+ * via asprintf(3)/vasprintf(3) calling libc internally.
+ */
+#if defined(BROKEN_SNPRINTF)
+# undef HAVE_VASPRINTF
+# undef HAVE_ASPRINTF
+#endif
+
#ifndef HAVE_VASPRINTF
#include <errno.h>
#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
@@ -90,7 +87,7 @@ int asprintf(char **str, const char *fmt, ...)
{
va_list ap;
int ret;
-
+
*str = NULL;
va_start(ap, fmt);
ret = vasprintf(str, fmt, ap);