summaryrefslogtreecommitdiff
path: root/lib/vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-07-06 16:55:33 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-07-06 17:35:25 +0200
commitecf3d1b9d5ff9bf11a9e79a8e4efb63eff4eb10e (patch)
tree4f0650a49a93ad7dc10be8726e47729b3aa19ad0 /lib/vty.c
parentca03eeeec736120e47fdc63bcb2ef1ad55be40b1 (diff)
lib: fix vty_out with >1024 bytes of output
Consuming va_args modifies its internal bits, hence the need to copy it... but the copying wasn't quite right just yet. Fixes: 4d5f445 ("lib: add vty_outln()") Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 145bcfe945..e6497b3100 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -107,7 +107,7 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args)
{
/* Try to write to initial buffer. */
va_copy (cp, args);
- len = vsnprintf (buf, sizeof(buf), format, args);
+ len = vsnprintf (buf, sizeof(buf), format, cp);
va_end (cp);
/* Initial buffer is not enough. */
@@ -124,7 +124,9 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args)
if (! p)
return -1;
- len = vsnprintf (p, size, format, args);
+ va_copy (cp, args);
+ len = vsnprintf (p, size, format, cp);
+ va_end (cp);
if (len > -1 && len < size)
break;