]> source.dussan.org Git - rspamd.git/commitdiff
Fix issues with freeing of bad rdns requests
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jan 2016 14:15:01 +0000 (14:15 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jan 2016 14:15:01 +0000 (14:15 +0000)
contrib/librdns/packet.c
src/libserver/rspamd_control.c

index 88e51dfba41c19cee18d0c1ff4d9ae264211b76b..630413fdbf863917edc5651fea78f91877227369 100644 (file)
@@ -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
index 2aab37b584e3fbed503c1212f1ea16cc1596d29c..6f0bd8a4ddce1d2d96aceea3357f09850c9468d6 100644 (file)
@@ -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