]> git.lizzy.rs Git - linenoise.git/commitdiff
Add an assertion for fd_printf() buffer size
authorSteve Bennett <steveb@workware.net.au>
Mon, 1 Jan 2018 03:23:48 +0000 (13:23 +1000)
committerSteve Bennett <steveb@workware.net.au>
Mon, 1 Jan 2018 03:41:47 +0000 (13:41 +1000)
Signed-off-by: Steve Bennett <steveb@workware.net.au>
linenoise.c

index aee34470d9316d317bd4afd15ca4e84c57246365..f6b9442f677517cdb4f2e0d4cb3a697cb9cf29f9 100644 (file)
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
@@ -290,6 +291,8 @@ static void fd_printf(int fd, const char *format, ...)
 
     va_start(args, format);
     n = vsnprintf(buf, sizeof(buf), format, args);
+    /* This will never happen because we are sure to use fd_printf() for short sequences */
+    assert(n < sizeof(buf));
     va_end(args);
     IGNORE_RC(write(fd, buf, n));
 }