Browse Source

Fix more issues found by coverity

tags/1.2.0
Vsevolod Stakhov 8 years ago
parent
commit
be13d1b8e4

+ 4
- 4
src/libserver/events.c View File

@@ -127,7 +127,7 @@ rspamd_session_add_event (struct rspamd_async_session *session,
struct rspamd_async_event *new;

if (session == NULL) {
msg_info_session ("session is NULL");
msg_err ("session is NULL");
return;
}

@@ -161,7 +161,7 @@ rspamd_session_remove_event (struct rspamd_async_session *session,
struct rspamd_async_event search_ev, *found_ev;

if (session == NULL) {
msg_info_session ("session is NULL");
msg_err ("session is NULL");
return;
}

@@ -213,7 +213,7 @@ gboolean
rspamd_session_destroy (struct rspamd_async_session *session)
{
if (session == NULL) {
msg_info_session ("session is NULL");
msg_err ("session is NULL");
return FALSE;
}

@@ -231,7 +231,7 @@ void
rspamd_session_cleanup (struct rspamd_async_session *session)
{
if (session == NULL) {
msg_info_session ("session is NULL");
msg_err ("session is NULL");
return;
}


+ 1
- 2
src/libserver/html.c View File

@@ -1070,9 +1070,8 @@ rspamd_html_parse_tag_content (rspamd_mempool_t *pool,
tag->id = found->id;
tag->flags = found->flags;
}
state = spaces_after_name;
}

state = spaces_after_name;
}
break;


+ 4
- 2
src/libserver/spf.c View File

@@ -760,8 +760,10 @@ parse_spf_domain_mask (struct spf_record *rec, struct spf_addr *addr,
/* Empty domain, technically an error */
state = parse_slash;
}
c = p;
state = parse_domain;
else {
c = p;
state = parse_domain;
}
break;
case parse_domain:
if (t == '/') {

+ 3
- 2
src/libserver/symbols_cache.c View File

@@ -746,9 +746,10 @@ rspamd_symbols_cache_validate_cb (gpointer k, gpointer v, gpointer ud)

/* Check whether this item is skipped */
skipped = !ghost;
g_assert (cache->cfg != NULL);

if ((item->type &
(SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_COMPOSITE|SYMBOL_TYPE_CLASSIFIER))
&& cache->cfg
&& g_hash_table_lookup (cache->cfg->metrics_symbols, item->symbol) == NULL) {
cur = g_list_first (cache->cfg->metrics_list);
while (cur) {
@@ -849,7 +850,7 @@ rspamd_symbols_cache_validate (struct symbols_cache *cache,
gboolean ignore_symbol = FALSE, ret = TRUE;

if (cache == NULL) {
msg_err_cache ("empty cache is invalid");
msg_err ("empty cache is invalid");
return FALSE;
}


+ 1
- 4
src/libserver/url.c View File

@@ -1588,10 +1588,7 @@ rspamd_tld_trie_find_callback (int strnum, int textpos, void *context)

if (*pos != '.' || textpos != (gint)cbdata->len) {
/* Something weird has been found */
if (textpos == (gint)cbdata->len - 1) {
pos = cbdata->begin + textpos;
}
else {
if (textpos != (gint)cbdata->len - 1) {
/* Search more */
return 0;
}

+ 16
- 2
src/libstat/backends/mmaped_file.c View File

@@ -346,12 +346,14 @@ rspamd_mmaped_file_check (rspamd_mempool_t *pool, rspamd_mmaped_file_t * file)
}

f = (struct stat_file *)file->map;
c = f->header.magic;
c = &f->header.magic[0];
/* Check magic and version */
if (*c++ != 'r' || *c++ != 's' || *c++ != 'd') {
msg_info_pool ("file %s is invalid stat file", file->filename);
return -1;
}

c = &f->header.version[0];
/* Now check version and convert old version to new one (that can be used for sync */
if (*c == 1 && *(c + 1) == 0) {
return -1;
@@ -414,6 +416,7 @@ rspamd_mmaped_file_reindex (rspamd_mempool_t *pool,
lock_fd = open (lock, O_RDONLY, 00600);
if (lock_fd != -1) {
if (!rspamd_file_lock (lock_fd, FALSE)) {
close (lock_fd);
g_free (lock);

return rspamd_mmaped_file_open (pool, filename, size, stcf);
@@ -608,8 +611,19 @@ rspamd_mmaped_file_open (rspamd_mempool_t *pool,
/* Try to lock pages in RAM */

/* Acquire lock for this operation */
rspamd_file_lock (new_file->fd, FALSE);
if (!rspamd_file_lock (new_file->fd, FALSE)) {
close (new_file->fd);
munmap (new_file->map, st.st_size);
msg_info_pool ("cannot lock file %s, error %d, %s",
filename,
errno,
strerror (errno));
g_slice_free1 (sizeof (*new_file), new_file);
return NULL;
}

if (rspamd_mmaped_file_check (pool, new_file) == -1) {
close (new_file->fd);
rspamd_file_unlock (new_file->fd, FALSE);
munmap (new_file->map, st.st_size);
g_slice_free1 (sizeof (*new_file), new_file);

+ 7
- 5
src/libstat/backends/redis_backend.c View File

@@ -111,22 +111,24 @@ rspamd_redis_expand_object (const gchar *pattern,
mod_char
} state = just_char;
struct rspamd_statfile_config *stcf;
lua_State *L;
lua_State *L = NULL;
struct rspamd_task **ptask;
GString *tb;
const gchar *rcpt = NULL;
gint err_idx;


g_assert (ctx != NULL);
stcf = ctx->stcf;
L = task->cfg->lua_state;

if (task) {
L = task->cfg->lua_state;
}

if (ctx->enable_users) {
if (ctx->cbref_user == -1) {
rcpt = rspamd_task_get_principal_recipient (task);
}
else {
else if (L) {
/* Execute lua function to get userdata */
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
@@ -357,7 +359,7 @@ rspamd_redis_tokens_to_query (struct rspamd_task *task, GPtrArray *tokens,
"%s\r\n"
"$%d\r\n"
"%s\r\n",
learn ? (tokens->len * 2 + 2) : (tokens->len + 2),
(tokens->len + 2),
larg0, arg0,
larg1, arg1);
}

Loading…
Cancel
Save