From 91516a1fd63de8423db146794f72bff8ec0191fa Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 14 Jan 2016 14:15:01 +0000 Subject: [PATCH] Fix issues with freeing of bad rdns requests --- contrib/librdns/packet.c | 14 +++++++++----- src/libserver/rspamd_control.c | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/librdns/packet.c b/contrib/librdns/packet.c index 88e51dfba..630413fdb 100644 --- a/contrib/librdns/packet.c +++ b/contrib/librdns/packet.c @@ -158,8 +158,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, } else { rdns_info ("no buffer remain for punycoding query"); - free (*out); - return false; + goto err; } free (uclabel); @@ -183,7 +182,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, } if (remain < label_len + 1) { rdns_info ("no buffer remain for punycoding query"); - return false; + goto err; } if (label_len == 0) { /* Two dots in order, skip this */ @@ -208,7 +207,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, } if (remain < label_len + 1) { rdns_info ("no buffer remain for punycoding query"); - return false; + goto err; } memcpy (o, p, label_len); o += label_len; @@ -220,7 +219,7 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, } if (remain == 0) { rdns_info ("no buffer remain for punycoding query"); - return false; + goto err; } } *o = '\0'; @@ -228,6 +227,11 @@ rdns_format_dns_name (struct rdns_resolver *resolver, const char *in, *outlen = o - *out; return true; + + err: + free (*out); + *out = NULL; + return false; } bool diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index 2aab37b58..6f0bd8a4d 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -700,6 +700,7 @@ rspamd_srv_handler (gint fd, short what, gpointer ud) break; case RSPAMD_SRV_HYPERSCAN_LOADED: /* Broadcast command to all workers */ + memset (&wcmd, 0, sizeof (wcmd)); wcmd.type = RSPAMD_CONTROL_HYPERSCAN_LOADED; /* * We assume that cache dir is shared at the same address for all -- 2.39.5