Commit a9667edc a9667edc912dc6d51031d09f9f5ded223851318a by Sergey Poznyakoff

Bugfix.

* libmailutils/string/vasnprintf.c (mu_vasnprintf): Operate on
a fresh copy of va_alist in each new iteration.
* libproto/imap/folder.c: Likewise.
* libproto/nntp/nntp_sendline.c: Likewise.
1 parent 5e1d982e
......@@ -46,7 +46,13 @@ mu_vasnprintf (char **pbuf, size_t *psize, const char *fmt, va_list ap)
for (;;)
{
ssize_t n = vsnprintf (buf, buflen, fmt, ap);
ssize_t n;
va_list aq;
va_copy(aq, ap);
n = vsnprintf (buf, buflen, fmt, aq);
va_end(aq);
if (n < 0 || n >= buflen || !memchr (buf, '\0', n + 1))
{
char *newbuf;
......
......@@ -2150,7 +2150,10 @@ imap_writeline (f_imap_t f_imap, const char *format, ...)
va_start(ap, format);
do
{
len = vsnprintf (f_imap->buffer, f_imap->buflen, format, ap);
va_list aq;
va_copy(aq, ap);
len = vsnprintf (f_imap->buffer, f_imap->buflen, format, aq);
va_end(aq);
if (len < 0 || len >= (int)f_imap->buflen
|| !memchr (f_imap->buffer, '\0', len + 1))
{
......
......@@ -88,7 +88,10 @@ mu_nntp_writeline (mu_nntp_t nntp, const char *format, ...)
let's try to cope. */
do
{
len = vsnprintf (nntp->io.buf, nntp->io.len - 1, format, ap);
va_list aq;
va_copy(aq, ap);
len = vsnprintf (nntp->io.buf, nntp->io.len - 1, format, aq);
va_end(aq);
if (len < 0 || len >= (int)nntp->io.len
|| !memchr (nntp->io.buf, '\0', len + 1))
{
......