preparing for release of 2.0.9
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index d9c87ec..5b16fc4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -633,26 +633,19 @@ int vslprintf(char *str, int n, const char *format, va_list ap)
                buf = malloc(len);
                if (!buf) {
                        /* can't call debug or we would recurse */
-                       exit(1);
+                       exit_cleanup(1);
                }
        }
 
-       ret = vsprintf(buf, format, ap);
-
-       if (ret < 0) {
-               str[0] = 0;
-               return -1;
-       }
-
-       if (ret < n) {
-               n = ret;
-       } else if (ret > n) {
-               ret = -1;
+       vsprintf(buf, format, ap);
+       ret = strlen(buf);
+       if (ret > n) {
+               /* yikes! */
+               exit_cleanup(1);
        }
-
-       buf[n] = 0;
+       buf[ret] = 0;
        
-       memcpy(str, buf, n+1);
+       memcpy(str, buf, ret+1);
 
        return ret;
 #endif
@@ -670,3 +663,4 @@ int slprintf(char *str, int n, char *format, ...)
        va_end(ap);
        return ret;
 }
+