diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-23 13:29:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-04-23 13:29:48 +0100 |
commit | 3c31e3680e05ea7a449691956ff8c7c424eb9521 (patch) | |
tree | 7d6aa6c6551ab33746f4f9b8c481509a3ce501c8 | |
parent | 58fa012f4bd6ee93ded8f10f24961ce6a1e0559e (diff) | |
download | rspamd-3c31e3680e05ea7a449691956ff8c7c424eb9521.tar.gz rspamd-3c31e3680e05ea7a449691956ff8c7c424eb9521.zip |
Fix issue with printing empty strings.
-rw-r--r-- | src/libutil/printf.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libutil/printf.c b/src/libutil/printf.c index 0c4c8f03d..195c04520 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -197,8 +197,12 @@ static glong rspamd_printf_append_file (const gchar *buf, glong buflen, gpointer ud) { FILE *dst = (FILE *)ud; - - return fwrite (buf, 1, buflen, dst); + if (buflen > 0) { + return fwrite (buf, 1, buflen, dst); + } + else { + return 0; + } } static glong @@ -206,7 +210,9 @@ rspamd_printf_append_gstring (const gchar *buf, glong buflen, gpointer ud) { GString *dst = (GString *)ud; - g_string_append_len (dst, buf, buflen); + if (buflen > 0) { + g_string_append_len (dst, buf, buflen); + } return buflen; } @@ -296,7 +302,7 @@ rspamd_printf_gstring (GString *s, const gchar *fmt, ...) #define RSPAMD_PRINTF_APPEND(buf, len) \ do { \ wr = func ((buf), (len), apd); \ - if (wr <= 0) { \ + if (wr < (__typeof(wr))(len)) { \ goto oob; \ } \ written += wr; \ @@ -439,7 +445,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func, gpointer apd, const gchar /* NULL terminated string */ slen = strlen (p); } - RSPAMD_PRINTF_APPEND (p, slen); continue; |