diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/http_connection.c | 19 | ||||
-rw-r--r-- | src/libutil/logger.c | 2 | ||||
-rw-r--r-- | src/libutil/map.c | 2 | ||||
-rw-r--r-- | src/libutil/mem_pool.c | 18 | ||||
-rw-r--r-- | src/libutil/multipattern.c | 1 | ||||
-rw-r--r-- | src/libutil/rrd.c | 13 | ||||
-rw-r--r-- | src/libutil/shingles.c | 4 |
7 files changed, 25 insertions, 34 deletions
diff --git a/src/libutil/http_connection.c b/src/libutil/http_connection.c index dc3bfa9c0..42b934d2a 100644 --- a/src/libutil/http_connection.c +++ b/src/libutil/http_connection.c @@ -722,10 +722,15 @@ rspamd_http_simple_client_helper (struct rspamd_http_connection *conn) priv = conn->priv; ssl = priv->ssl; priv->ssl = NULL; - request_method = priv->msg->method; - /* Preserve host for keepalive */ - prev_host = priv->msg->host; - priv->msg->host = NULL; + + /* Preserve data */ + if (priv->msg) { + request_method = priv->msg->method; + /* Preserve host for keepalive */ + prev_host = priv->msg->host; + priv->msg->host = NULL; + } + rspamd_http_connection_reset (conn); priv->ssl = ssl; @@ -1988,12 +1993,6 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn "" "\r\n", ENCRYPTED_VERSION, bodylen); } - - preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n" - "Content-Length: %z\r\n" - "Content-Type: %s\r\n" - "\r\n", ENCRYPTED_VERSION, bodylen, - mime_type); } else { preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), diff --git a/src/libutil/logger.c b/src/libutil/logger.c index 45e99f8ae..7eb00f3fa 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -925,7 +925,7 @@ file_log_function (const gchar *module, const gchar *id, gchar *m; gdouble now; - struct iovec iov[5]; + struct iovec iov[6]; gulong r = 0, mr = 0; guint64 cksum; size_t mlen, mremain; diff --git a/src/libutil/map.c b/src/libutil/map.c index d4687e433..0f7ff4f48 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -2685,7 +2685,7 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg, } } - if (map->backends->len == 0) { + if (!map->backends || map->backends->len == 0) { msg_err_config ("map has no urls to be loaded: no valid backends"); goto err; } diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c index 2f39a116d..a519013d1 100644 --- a/src/libutil/mem_pool.c +++ b/src/libutil/mem_pool.c @@ -490,9 +490,9 @@ void * rspamd_mempool_alloc0 (rspamd_mempool_t * pool, gsize size) { void *pointer = rspamd_mempool_alloc (pool, size); - if (pointer) { - memset (pointer, 0, size); - } + + memset (pointer, 0, size); + return pointer; } @@ -500,9 +500,9 @@ void * rspamd_mempool_alloc0_tmp (rspamd_mempool_t * pool, gsize size) { void *pointer = rspamd_mempool_alloc_tmp (pool, size); - if (pointer) { - memset (pointer, 0, size); - } + + memset (pointer, 0, size); + return pointer; } @@ -510,9 +510,8 @@ void * rspamd_mempool_alloc0_shared (rspamd_mempool_t * pool, gsize size) { void *pointer = rspamd_mempool_alloc_shared (pool, size); - if (pointer) { - memset (pointer, 0, size); - } + + memset (pointer, 0, size); return pointer; } @@ -800,7 +799,6 @@ rspamd_mempool_stat (rspamd_mempool_stat_t * st) st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; st->bytes_allocated = mem_pool_stat->bytes_allocated; st->chunks_allocated = mem_pool_stat->chunks_allocated; - st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; st->chunks_freed = mem_pool_stat->chunks_freed; st->oversized_chunks = mem_pool_stat->oversized_chunks; } diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c index 268170512..5f5724a0c 100644 --- a/src/libutil/multipattern.c +++ b/src/libutil/multipattern.c @@ -209,7 +209,6 @@ rspamd_multipattern_pattern_filter (const gchar *pattern, gsize len, g_free (tmp); } else if (flags & RSPAMD_MULTIPATTERN_RE) { - ret = malloc (len + 1); ret = rspamd_str_regexp_escape (pattern, len, dst_len, gl_flags | RSPAMD_REGEXP_ESCAPE_RE); } diff --git a/src/libutil/rrd.c b/src/libutil/rrd.c index 95d78c7f5..d17e823e6 100644 --- a/src/libutil/rrd.c +++ b/src/libutil/rrd.c @@ -228,12 +228,6 @@ rspamd_rrd_check_file (const gchar *filename, gboolean need_data, GError **err) close (fd); return FALSE; } - if (memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0) { - g_set_error (err, - rrd_error_quark (), EINVAL, "rrd head error: invalid version"); - close (fd); - return FALSE; - } if (head.float_cookie != RRD_FLOAT_COOKIE) { g_set_error (err, rrd_error_quark (), EINVAL, "rrd head error: another architecture " @@ -409,16 +403,12 @@ rspamd_rrd_open_common (const gchar *filename, gboolean completed, GError **err) file = g_malloc0 (sizeof (struct rspamd_rrd_file)); - if (file == NULL) { - g_set_error (err, rrd_error_quark (), ENOMEM, "not enough memory"); - return NULL; - } - /* Open file */ fd = rspamd_rrd_open_exclusive (filename); if (fd == -1) { g_set_error (err, rrd_error_quark (), errno, "rrd open error: %s", strerror (errno)); + g_free (file); return FALSE; } @@ -426,6 +416,7 @@ rspamd_rrd_open_common (const gchar *filename, gboolean completed, GError **err) g_set_error (err, rrd_error_quark (), errno, "rrd stat error: %s", strerror (errno)); rspamd_file_unlock (fd, FALSE); + g_free (file); close (fd); return FALSE; } diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index 70aa5fe78..4affb16c3 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -184,6 +184,10 @@ rspamd_shingles_from_text (GArray *input, g_free (hashes); + if (pool != NULL) { + g_free (res); + } + return NULL; } |