]> source.dussan.org Git - rspamd.git/commitdiff
Fix dereferencing of NULL pointer.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Mar 2015 11:08:14 +0000 (11:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 Mar 2015 11:08:14 +0000 (11:08 +0000)
src/libserver/roll_history.c
src/libutil/addr.c

index 2f5c5ddb37e34ff1181d79e52cadc95f8d3f79fb..c494ce74cdf14d893f9821ae78e69d1bc1183a87 100644 (file)
@@ -109,9 +109,15 @@ rspamd_roll_history_update (struct roll_history *history,
        }
 
        /* Add information from task to roll history */
-       rspamd_strlcpy (row->from_addr,
-                       rspamd_inet_address_to_string (task->from_addr),
-                       sizeof (row->from_addr));
+       if (task->from_addr) {
+               rspamd_strlcpy (row->from_addr,
+                               rspamd_inet_address_to_string (task->from_addr),
+                               sizeof (row->from_addr));
+       }
+       else {
+               rspamd_strlcpy (row->from_addr, "unknown", sizeof (row->from_addr));
+       }
+
        memcpy (&row->tv,                &task->tv,                sizeof (row->tv));
 
        /* Strings */
index 3e2ec9458c13a3ea2148f4266b30eef02e3c4e3d..38cd7320079744c9bd7470cc56dcb3dc96595727 100644 (file)
@@ -381,6 +381,10 @@ rspamd_inet_address_to_string (const rspamd_inet_addr_t *addr)
 {
        static char addr_str[INET6_ADDRSTRLEN + 1];
 
+       if (addr == NULL) {
+               return "<empty inet address>";
+       }
+
        switch (addr->af) {
        case AF_INET:
                return inet_ntop (addr->af, &addr->u.in.addr.s4.sin_addr, addr_str,