From: Vsevolod Stakhov Date: Sat, 28 Mar 2015 11:08:14 +0000 (+0000) Subject: Fix dereferencing of NULL pointer. X-Git-Tag: 0.9.0~399 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8beb6fe20a322fe72faaabf8507503f138dbeb73;p=rspamd.git Fix dereferencing of NULL pointer. --- diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c index 2f5c5ddb3..c494ce74c 100644 --- a/src/libserver/roll_history.c +++ b/src/libserver/roll_history.c @@ -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 */ diff --git a/src/libutil/addr.c b/src/libutil/addr.c index 3e2ec9458..38cd73200 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -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 ""; + } + switch (addr->af) { case AF_INET: return inet_ntop (addr->af, &addr->u.in.addr.s4.sin_addr, addr_str,