Fix crash in conf, improves debug logging for rbl.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 5 Oct 2008 16:12:44 +0000 (18:12 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 5 Oct 2008 16:12:44 +0000 (18:12 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
common/rbl.c
postlicyd/config.c
postlicyd/iplist.c
postlicyd/strlist.c

index 11ed464..0ae4979 100644 (file)
 
 static inline rbl_result_t rbl_dns_check(const char *hostname)
 {
+    debug("looking up for %s", hostname);
     struct hostent *host = gethostbyname(hostname);
     if (host != NULL) {
+        debug("host found");
         return RBL_FOUND;
     } else {
         if (h_errno == HOST_NOT_FOUND) {
+            debug("host not found: %s", hostname);
             return RBL_NOTFOUND;
         }
+        debug("dns error: %m");
         return RBL_ERROR;
     }
 }
index d4131f1..f2b8dbe 100644 (file)
@@ -423,7 +423,7 @@ config_t *config_read(const char *file)
     config_t *config = config_new();
     config->filename = file;
     if (!config_reload(config)) {
-        p_delete(&config);
+        config_delete(&config);
         return NULL;
     }
     return config;
index 3c14fda..5337dca 100644 (file)
@@ -378,7 +378,7 @@ static bool rbl_filter_constructor(filter_t *filter)
         }
     }}
 
-    PARSE_CHECK(data->rbls.len
+    PARSE_CHECK(data->rbls.len || data->host_offsets.len,
                 "no file parameter in the filter %s", filter->name);
     filter->data = data;
     return true;
index 2f17f90..c350f22 100644 (file)
@@ -487,7 +487,7 @@ static bool strlist_filter_constructor(filter_t *filter)
 
     PARSE_CHECK(config->is_email != config->is_hostname,
                 "matched field MUST be emails XOR hostnames");
-    PARSE_CHECK(config->tries.len,
+    PARSE_CHECK(config->tries.len || config->host_offsets.len,
                 "no file parameter in the filter %s", filter->name);
     filter->data = config;
     return true;
@@ -543,7 +543,7 @@ static filter_result_t strlist_filter(const filter_t *filter, const query_t *que
     if (config->match_ ## Flag) {                                              \
         const int len = m_strlen(query->Field);                                \
         strlist_copy(normal, query->Field, len, false);                        \
-        for (uint32_t i = 0 ; len > 0 && i < config->tries.len ; ++i) {        \
+        for (uint32_t i = 0 ; len > 0 && i < config->host_offsets.len ; ++i) { \
             const char *rbl    = array_ptr(config->hosts,                      \
                                            array_elt(config->host_offsets, i));\
             const int weight   = array_elt(config->host_weights, i);           \