diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controller.c | 2 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/memcached.c | 19 | ||||
-rw-r--r-- | src/plugins/surbl.c | 21 | ||||
-rw-r--r-- | src/protocol.c | 4 | ||||
-rw-r--r-- | src/statfile.c | 2 | ||||
-rw-r--r-- | src/util.c | 14 |
7 files changed, 43 insertions, 21 deletions
diff --git a/src/controller.c b/src/controller.c index 393bc2347..b85db1b2d 100644 --- a/src/controller.c +++ b/src/controller.c @@ -179,7 +179,7 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control } /* If uptime is less than 1 minute print only seconds */ else if (uptime / 60 == 0) { - r = snprintf (out_buf, sizeof (out_buf), "%dsecond%s", uptime, uptime > 1 ? "s" : " "); + r = snprintf (out_buf, sizeof (out_buf), "%dsecond%s", (int)uptime, (int)uptime > 1 ? "s" : " "); } /* Else print the minutes and seconds. */ else { diff --git a/src/main.c b/src/main.c index 445b0e42b..64ac455a7 100644 --- a/src/main.c +++ b/src/main.c @@ -158,7 +158,7 @@ fork_worker (struct rspamd_main *rspamd, int listen_sock, int reconfig, enum pro } int -main (int argc, char **argv) +main (int argc, char **argv, char **env) { struct rspamd_main *rspamd; struct module_ctx *cur_module = NULL; diff --git a/src/memcached.c b/src/memcached.c index 05ae16617..22dd9fbb3 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -105,7 +105,9 @@ write_handler (int fd, short what, memcached_ctx_t *ctx) iov[2].iov_len = ctx->param->bufsize - ctx->param->bufpos; iov[3].iov_base = CRLF; iov[3].iov_len = sizeof (CRLF) - 1; - writev (ctx->sock, iov, 4); + if (writev (ctx->sock, iov, 4) == -1) { + memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + } } else { iov[0].iov_base = read_buf; @@ -195,10 +197,14 @@ read_handler (int fd, short what, memcached_ctx_t *ctx) iov[0].iov_len = sizeof (struct memc_udp_header); iov[1].iov_base = read_buf; iov[1].iov_len = r; - writev (ctx->sock, iov, 2); + if (writev (ctx->sock, iov, 2) == -1) { + memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + } } else { - write (ctx->sock, read_buf, r); + if (write (ctx->sock, read_buf, r) == -1) { + memc_log (ctx, __LINE__, "memc_write: write failed: %m"); + } } event_del (&ctx->mem_ev); event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx); @@ -325,9 +331,14 @@ delete_handler (int fd, short what, memcached_ctx_t *ctx) iov[1].iov_base = read_buf; iov[1].iov_len = r; ctx->param->bufpos = writev (ctx->sock, iov, 2); + if (ctx->param->bufpos == -1) { + memc_log (ctx, __LINE__, "memc_write: writev failed: %m"); + } } else { - write (ctx->sock, read_buf, r); + if (write (ctx->sock, read_buf, r) == -1) { + memc_log (ctx, __LINE__, "memc_write: write failed: %m"); + } } event_del (&ctx->mem_ev); event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx); diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index c90a8419e..07e2376bf 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -337,7 +337,7 @@ memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data) switch (ctx->op) { case CMD_CONNECT: if (error != OK) { - msg_info ("memcached_callback: memcached returned error %s on CONNECT stage"); + msg_info ("memcached_callback: memcached returned error %s on CONNECT stage", memc_strerror (error)); memc_close_ctx (param->ctx); param->task->save.saved --; if (param->task->save.saved == 0) { @@ -356,7 +356,7 @@ memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data) break; case CMD_READ: if (error != OK) { - msg_info ("memcached_callback: memcached returned error %s on READ stage"); + msg_info ("memcached_callback: memcached returned error %s on READ stage", memc_strerror (error)); memc_close_ctx (param->ctx); param->task->save.saved --; if (param->task->save.saved == 0) { @@ -382,7 +382,7 @@ memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data) break; case CMD_WRITE: if (error != OK) { - msg_info ("memcached_callback: memcached returned error %s on WRITE stage"); + msg_info ("memcached_callback: memcached returned error %s on WRITE stage", memc_strerror (error)); } memc_close_ctx (param->ctx); param->task->save.saved --; @@ -428,7 +428,7 @@ register_memcached_call (struct uri *url, struct worker_task *task) cur_param->bufsize = sizeof (int); sum_str = g_compute_checksum_for_string (G_CHECKSUM_MD5, struri (url), -1); - strlcpy (cur_param->key, sum_str, sizeof (cur_param->key)); + g_strlcpy (cur_param->key, sum_str, sizeof (cur_param->key)); g_free (sum_str); selected = (struct memcached_server *) get_upstream_by_hash ((void *)task->cfg->memcached_servers, @@ -471,7 +471,18 @@ redirector_callback (int fd, short what, void *arg) event_set (¶m->ev, param->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, redirector_callback, (void *)param); event_add (¶m->ev, &timeout); r = snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url)); - write (param->sock, url_buf, r); + if (write (param->sock, url_buf, r) == -1) { + msg_err ("redirector_callback: write failed %m"); + event_del (¶m->ev); + param->task->save.saved --; + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } + g_free (param); + return; + } param->state = STATE_READ; } else { diff --git a/src/protocol.c b/src/protocol.c index b259f6cd9..027e3a91a 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -349,7 +349,7 @@ write_check_reply (struct worker_task *task) char outbuf[OUTBUFSIZ]; struct metric_result *metric_res; - r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER); + r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK"); bufferevent_write (task->bev, outbuf, r); if (task->proto == SPAMC_PROTO) { /* Ignore metrics, just write report for 'default' metric */ @@ -435,7 +435,7 @@ write_process_reply (struct worker_task *task) char outbuf[OUTBUFSIZ]; r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF "Content-Length: %zd" CRLF CRLF, - (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, task->msg->buf->len); + (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK", task->msg->buf->len); bufferevent_write (task->bev, outbuf, r); bufferevent_write (task->bev, task->msg->buf->begin, task->msg->buf->len); diff --git a/src/statfile.c b/src/statfile.c index fc7ebfc7a..3f68a1de2 100644 --- a/src/statfile.c +++ b/src/statfile.c @@ -117,7 +117,7 @@ statfile_pool_open (statfile_pool_t *pool, char *filename) } if (st.st_size > pool->max) { - msg_info ("statfile_pool_open: cannot attach file to pool, too large: %zd", st.st_size); + msg_info ("statfile_pool_open: cannot attach file to pool, too large: %zd", (size_t)st.st_size); return -1; } diff --git a/src/util.c b/src/util.c index 828c3d518..f4978b5b7 100644 --- a/src/util.c +++ b/src/util.c @@ -673,7 +673,7 @@ parse_expression (memory_pool_t *pool, char *line) if (c != p) { /* Copy operand */ str = memory_pool_alloc (pool, p - c + 1); - strlcpy (str, c, (p - c + 1)); + g_strlcpy (str, c, (p - c + 1)); insert_expression (pool, &expr, EXPR_OPERAND, 0, str); } if (*p == ')') { @@ -724,7 +724,7 @@ parse_expression (memory_pool_t *pool, char *line) if (c != p) { /* Copy operand */ str = memory_pool_alloc (pool, p - c + 1); - strlcpy (str, c, (p - c + 1)); + g_strlcpy (str, c, (p - c + 1)); insert_expression (pool, &expr, EXPR_OPERAND, 0, str); } /* Pop everything from stack */ @@ -750,7 +750,7 @@ open_log (struct config_file *cfg) openlog ("rspamd", LOG_NDELAY | LOG_PID, cfg->log_facility); return 0; case RSPAMD_LOG_FILE: - cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND); + cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (cfg->log_fd == -1) { msg_err ("open_log: cannot open desired log file: %s, %m", cfg->log_file); return -1; @@ -787,16 +787,16 @@ syslog_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gc if (log_level <= cfg->log_level) { if (log_level >= G_LOG_LEVEL_DEBUG) { - syslog (LOG_DEBUG, message); + syslog (LOG_DEBUG, "%s", message); } else if (log_level >= G_LOG_LEVEL_INFO) { - syslog (LOG_INFO, message); + syslog (LOG_INFO, "%s", message); } else if (log_level >= G_LOG_LEVEL_WARNING) { - syslog (LOG_WARNING, message); + syslog (LOG_WARNING, "%s", message); } else if (log_level >= G_LOG_LEVEL_CRITICAL) { - syslog (LOG_ERR, message); + syslog (LOG_ERR, "%s", message); } } } |