summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-28 11:08:14 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-28 11:08:14 +0000
commit8beb6fe20a322fe72faaabf8507503f138dbeb73 (patch)
tree7364db81d8e8f9b1421cf51923130de30904d5d4 /src
parent51319cbd3cf0050add4d7743653eb2626784f7bd (diff)
downloadrspamd-8beb6fe20a322fe72faaabf8507503f138dbeb73.tar.gz
rspamd-8beb6fe20a322fe72faaabf8507503f138dbeb73.zip
Fix dereferencing of NULL pointer.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/roll_history.c12
-rw-r--r--src/libutil/addr.c4
2 files changed, 13 insertions, 3 deletions
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 "<empty inet address>";
+ }
+
switch (addr->af) {
case AF_INET:
return inet_ntop (addr->af, &addr->u.in.addr.s4.sin_addr, addr_str,