From: Andrew Tridgell Date: Sat, 16 May 1998 00:46:16 +0000 (+0000) Subject: fixed handling of vsprintf on SunOS X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/f72399f8674aca5eae57b7981a233c7f4b95fb11 fixed handling of vsprintf on SunOS --- diff --git a/util.c b/util.c index d9c87ece..04420048 100644 --- a/util.c +++ b/util.c @@ -637,22 +637,15 @@ int vslprintf(char *str, int n, const char *format, va_list ap) } } - ret = vsprintf(buf, format, ap); - - if (ret < 0) { - str[0] = 0; - return -1; + vsprintf(buf, format, ap); + ret = strlen(buf); + if (ret > n) { + /* yikes! */ + exit(1); } - - if (ret < n) { - n = ret; - } else if (ret > n) { - ret = -1; - } - - buf[n] = 0; + buf[ret] = 0; - memcpy(str, buf, n+1); + memcpy(str, buf, ret+1); return ret; #endif