summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2002-05-17 14:51:22 +0000
committerJim McDonough <jmcd@samba.org>2002-05-17 14:51:22 +0000
commitc7523c57512258007f0ac5271697fc6a9f4618d6 (patch)
tree43ab98ce3e97f2a910c15ef76978bb46a8471407 /source3
parent31cda568c05624ef5e7fd2970c5f2733e67eedc3 (diff)
downloadsamba-c7523c57512258007f0ac5271697fc6a9f4618d6.tar.gz
samba-c7523c57512258007f0ac5271697fc6a9f4618d6.tar.bz2
samba-c7523c57512258007f0ac5271697fc6a9f4618d6.zip
Fix usage of va_list passed as an arg. Use __va_copy before using it
when it exists. (This used to be commit 85ab07bdc1b2ce7b2c1b8197fad45124b1460dca)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/dprintf.c8
-rw-r--r--source3/lib/snprintf.c25
-rw-r--r--source3/lib/util.c8
-rw-r--r--source3/lib/xfile.c8
4 files changed, 42 insertions, 7 deletions
diff --git a/source3/lib/dprintf.c b/source3/lib/dprintf.c
index dadebdb3b4..4dcc283047 100644
--- a/source3/lib/dprintf.c
+++ b/source3/lib/dprintf.c
@@ -36,12 +36,18 @@ int d_vfprintf(FILE *f, const char *format, va_list ap)
char *p, *p2;
int ret, maxlen, clen;
const char *msgstr;
+ va_list ap2;
/* do any message translations */
msgstr = lang_msg(format);
if (!msgstr) return -1;
- ret = vasprintf(&p, msgstr, ap);
+#if defined(HAVE_VA_COPY)
+ __va_copy(ap2, ap)
+#else
+ ap2 = ap;
+#endif
+ ret = vasprintf(&p, msgstr, ap2);
lang_msg_free(msgstr);
diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c
index ee0d302b0f..561e775c8f 100644
--- a/source3/lib/snprintf.c
+++ b/source3/lib/snprintf.c
@@ -106,7 +106,7 @@
#endif
static size_t dopr(char *buffer, size_t maxlen, const char *format,
- va_list args);
+ va_list args_in);
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
char *value, int flags, int min, int max);
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
@@ -149,7 +149,7 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
#endif
-static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
+static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
{
char ch;
LLONG value;
@@ -161,6 +161,13 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
int flags;
int cflags;
size_t currlen;
+ va_list args;
+
+#if defined(HAVE_VA_COPY)
+ __va_copy(args, args_in);
+#else
+ args = args_in;
+#endif
state = DP_S_DEFAULT;
currlen = flags = cflags = min = 0;
@@ -793,13 +800,23 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
int vasprintf(char **ptr, const char *format, va_list ap)
{
int ret;
+ va_list ap2;
+
+#if defined(HAVE_VA_COPY)
+ __va_copy(ap2, ap);
+#else
+ ap2 = ap;
+#endif
- ret = vsnprintf(NULL, 0, format, ap);
+ ret = vsnprintf(NULL, 0, format, ap2);
if (ret <= 0) return ret;
(*ptr) = (char *)malloc(ret+1);
if (!*ptr) return -1;
- ret = vsnprintf(*ptr, ret+1, format, ap);
+#if defined(HAVE_VA_COPY)
+ __va_copy(ap2, ap);
+#endif
+ ret = vsnprintf(*ptr, ret+1, format, ap2);
return ret;
}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index bb9b96b361..d9be67599f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1815,7 +1815,13 @@ char *smb_xstrdup(const char *s)
int smb_xvasprintf(char **ptr, const char *format, va_list ap)
{
int n;
- n = vasprintf(ptr, format, ap);
+ va_list ap2;
+#if defined(HAVE_VA_COPY)
+ __va_copy(ap2, ap);
+#else
+ ap2 = ap;
+#endif
+ n = vasprintf(ptr, format, ap2);
if (n == -1 || ! *ptr) {
smb_panic("smb_xvasprintf: out of memory");
}
diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c
index 00ea6e5cac..7b97d329ae 100644
--- a/source3/lib/xfile.c
+++ b/source3/lib/xfile.c
@@ -187,7 +187,13 @@ int x_vfprintf(XFILE *f, const char *format, va_list ap)
{
char *p;
int len, ret;
- len = vasprintf(&p, format, ap);
+ va_list ap2;
+#if defined(HAVE_VA_COPY)
+ __va_copy(ap2, ap);
+#else
+ ap2 = ap;
+#endif
+ len = vasprintf(&p, format, ap2);
if (len <= 0) return len;
ret = x_fwrite(p, 1, len, f);
SAFE_FREE(p);