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
{
GString *dst = (GString *)ud;
- g_string_append_len (dst, buf, buflen);
+ if (buflen > 0) {
+ g_string_append_len (dst, buf, buflen);
+ }
return buflen;
}
#define RSPAMD_PRINTF_APPEND(buf, len) \
do { \
wr = func ((buf), (len), apd); \
- if (wr <= 0) { \
+ if (wr < (__typeof(wr))(len)) { \
goto oob; \
} \
written += wr; \
/* NULL terminated string */
slen = strlen (p);
}
-
RSPAMD_PRINTF_APPEND (p, slen);
continue;