diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-10-26 23:23:45 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-10-26 23:23:45 +0000 |
commit | f8be5ef4cb86bee9227b14b41238ac867c820759 (patch) | |
tree | e5303656dece5ef2e7a7d32688196a188dc61822 /util.c | |
parent | 587cb08dc4d83a005bfd6534d20d83ffe33e237d (diff) | |
download | rsync-f8be5ef4cb86bee9227b14b41238ac867c820759.tar.gz |
added a vsnprintf() implementation from cvslock. See the notes on the
license at the top of lib/snprintf.c
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 37 |
1 files changed, 0 insertions, 37 deletions
@@ -507,7 +507,6 @@ void strlower(char *s) pass 1023 for n */ int vslprintf(char *str, int n, const char *format, va_list ap) { -#ifdef HAVE_VSNPRINTF int ret = vsnprintf(str, n, format, ap); if (ret > n || ret < 0) { str[n] = 0; @@ -515,42 +514,6 @@ int vslprintf(char *str, int n, const char *format, va_list ap) } str[ret] = 0; return ret; -#else - static char *buf; - static int len=MAXPATHLEN*8; - int ret; - - /* this code is NOT a proper vsnprintf() implementation. It - relies on the fact that all calls to slprintf() in rsync - pass strings which have already been checked to be less - than MAXPATHLEN in length and never more than 2 strings are - concatenated. This means the above buffer is absolutely - ample and can never be overflowed. - - In the future we would like to replace this with a proper - vsnprintf() implementation but right now we need a solution - that is secure and portable. This is it. */ - - if (!buf) { - buf = malloc(len); - if (!buf) { - /* can't call debug or we would recurse */ - exit_cleanup(1); - } - } - - vsprintf(buf, format, ap); - ret = strlen(buf); - if (ret > n) { - /* yikes! */ - exit_cleanup(1); - } - buf[ret] = 0; - - memcpy(str, buf, ret+1); - - return ret; -#endif } |