summary refs log tree commit diff
path: root/src/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/output.c')
-rw-r--r--src/output.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/output.c b/src/output.c
index 2f9b5c4..f62e7ea 100644
--- a/src/output.c
+++ b/src/output.c
@@ -378,6 +378,20 @@ xvsnprintf(char *outbuf, size_t length, const char *fmt, va_list ap)
 {
 	int ret;
 
+#ifdef __sun
+	/*
+	 * vsnprintf() on older versions of Solaris returns -1 when
+	 * passed a length of 0.  To avoid this, use a dummy
+	 * 1-character buffer instead.
+	 */
+	char dummy[1];
+
+	if (length == 0) {
+		outbuf = dummy;
+		length = sizeof(dummy);
+	}
+#endif
+
 	INTOFF;
 	ret = vsnprintf(outbuf, length, fmt, ap);
 	INTON;