diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-24 20:57:05 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-24 20:57:05 +0400 |
commit | 62108fe767966d44e43f4b23094f220dd0d6bf27 (patch) | |
tree | b87a61491189f85f57f387ee99e7844f750a92c1 /src/util.c | |
parent | 4536c2547b508cfa575218f6ebc147bf471ba465 (diff) | |
download | rspamd-62108fe767966d44e43f4b23094f220dd0d6bf27.tar.gz rspamd-62108fe767966d44e43f4b23094f220dd0d6bf27.zip |
* Use rspamd_snprintf instead of libc one
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 67b93337e..9a82a25f6 100644 --- a/src/util.c +++ b/src/util.c @@ -1124,8 +1124,9 @@ rspamd_snprintf (u_char *buf, size_t max, const char *fmt, ...) va_list args; va_start (args, fmt); - p = rspamd_vsnprintf (buf, max, fmt, args); + p = rspamd_vsnprintf (buf, max - 1, fmt, args); va_end (args); + *p = '\0'; return p - buf; } @@ -1208,7 +1209,12 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args) break; case '*': - slen = va_arg(args, size_t); + d = (int)va_arg (args, int); + if (G_UNLIKELY (d < 0)) { + msg_err ("crititcal error: size is less than 0"); + g_assert (0); + } + slen = (size_t)d; fmt++; continue; |