]> source.dussan.org Git - rspamd.git/commitdiff
Fix some warnings that actually are dangerous.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jun 2013 15:24:15 +0000 (16:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 3 Jun 2013 15:24:15 +0000 (16:24 +0100)
src/dkim.c
src/lua_worker.c
src/plugins/regexp.c
src/protocol.c
src/smtp_proxy.c

index 157b13aee48d75e8cfaee05b55ee8fff1268cb75..5e62ab55de3798b1c3c11917aa309fe99aa0d15b 100644 (file)
@@ -367,7 +367,7 @@ rspamd_dkim_parse_bodylength (rspamd_dkim_context_t* ctx, const gchar *param, gs
 rspamd_dkim_context_t*
 rspamd_create_dkim_context (const gchar *sig, memory_pool_t *pool, guint time_jitter, GError **err)
 {
-       const gchar                                             *p, *c, *tag, *end;
+       const gchar                                             *p, *c, *tag = NULL, *end;
        gsize                                                    taglen;
        gint                                                     param = DKIM_PARAM_UNKNOWN;
        time_t                                                   now;
index c4276968a89c20961774fc5f874943ccaf9cecd0..723c48707041d1ec2d1631d585756d2e6d9b14a2 100644 (file)
@@ -381,6 +381,20 @@ lua_accept_socket (gint fd, short what, void *arg)
                                sizeof (struct in_addr));
                addr_str = g_strdup (inet_ntoa (su.s4.sin_addr));
        }
+       else if (su.ss.ss_family == AF_INET6) {
+               addr_str = g_malloc0 (INET6_ADDRSTRLEN + 1);
+               /* XXX: support ipv6 addresses here */
+               addr.s_addr = INADDR_NONE;
+               inet_ntop (AF_INET6, &su.s6.sin6_addr, addr_str, INET6_ADDRSTRLEN);
+               msg_info ("accepted connection from [%s] port %d",
+                                               addr_str, ntohs (su.s6.sin6_port));
+       }
+       else {
+               addr.s_addr = INADDR_NONE;
+               msg_err ("accepted connection from unsupported address family: %d", su.ss.ss_family);
+               close (nfd);
+               return;
+       }
 
        /* Call finalizer function */
        lua_rawgeti (L, LUA_REGISTRYINDEX, ctx->cbref_accept);
index 27280554817c02b4a7cbbb035604ea0a0beb67ab..91543d2c4011fd5603e5ce397c3a31472e50fa9b 100644 (file)
@@ -1151,7 +1151,8 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res)
 }
 
 static                          gboolean
-process_regexp_expression (struct expression *expr, gchar *symbol, struct worker_task *task, const gchar *additional, struct lua_locked_state *nL)
+process_regexp_expression (struct expression *expr, gchar *symbol, struct worker_task *task,
+               const gchar *additional, struct lua_locked_state *nL)
 {
        GQueue                         *stack;
        gsize                           cur, op1, op2;
@@ -1192,15 +1193,13 @@ process_regexp_expression (struct expression *expr, gchar *symbol, struct worker
                }
                else if (it->type == EXPR_STR) {
                        /* This may be lua function, try to call it */
-                       if (regexp_module_ctx->workers != NULL) {
-                               if (nL) {
-                                       rspamd_mutex_lock (nL->m);
-                                       cur = maybe_call_lua_function ((const gchar*)it->content.operand, task, nL->L);
-                                       rspamd_mutex_unlock (nL->m);
-                               }
-                               else {
-                                       cur = maybe_call_lua_function ((const gchar*)it->content.operand, task, task->cfg->lua_state);
-                               }
+                       if (nL) {
+                               rspamd_mutex_lock (nL->m);
+                               cur = maybe_call_lua_function ((const gchar*)it->content.operand, task, nL->L);
+                               rspamd_mutex_unlock (nL->m);
+                       }
+                       else {
+                               cur = maybe_call_lua_function ((const gchar*)it->content.operand, task, task->cfg->lua_state);
                        }
                        debug_task ("function %s returned %s", (const gchar *)it->content.operand, cur ? "true" : "false");
                        if (try_optimize) {
index 151b59a9f975f7130779db6aa2cc7b30e60d7fb9..ffc56bde673c2a89862220d3ce49a5e317150b14 100644 (file)
@@ -1141,12 +1141,12 @@ print_metric_data_json (struct worker_task *task, gchar *outbuf, gsize size,
        gint                            r = 0;
        gchar                                                   *local_act;
 
-       if (task->pre_result.action == METRIC_ACTION_NOACTION) {
-               local_act = "False";
-       }
-       else if (task->pre_result.action <= METRIC_ACTION_SOFT_REJECT) {
+       if (task->pre_result.action <= METRIC_ACTION_SOFT_REJECT) {
                local_act = "True";
        }
+       else {
+               local_act = "False";
+       }
        if (metric_res == NULL) {
                /* This is case when we got reject result from pre filters */
                r = rspamd_snprintf (outbuf, size,
index e7856898d1f42383f59daf6bd213046139747a57..e90be31fe50cf69e1cc892c55ab298f8ca7d7611 100644 (file)
@@ -217,7 +217,9 @@ free_smtp_proxy_session (gpointer arg)
                if (session->state != SMTP_PROXY_STATE_PROXY && session->state != SMTP_PROXY_STATE_REJECT &&
                                session->state != SMTP_PROXY_STATE_REJECT_EMULATE) {
                        /* Send 521 fatal error */
-                       write (session->sock, fatal_smtp_error, sizeof (fatal_smtp_error));
+                       if (write (session->sock, fatal_smtp_error, sizeof (fatal_smtp_error)) == -1) {
+                               msg_err ("write error to client failed: %s", strerror (errno));
+                       }
                }
                else if ((session->state == SMTP_PROXY_STATE_REJECT || session->state == SMTP_PROXY_STATE_REJECT_EMULATE) &&
                                session->from && session->rcpt && session->dnsbl_applied) {