summaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
commit1e08514471896e3b3069cdc25f457036d257cc68 (patch)
treeb591aa5d3eac5fec70d137d664ccc4b95db63cc4 /src/libutil
parent9068c5040e2737ce70f0cc9498000efa30c14c74 (diff)
downloadrspamd-1e08514471896e3b3069cdc25f457036d257cc68.tar.gz
rspamd-1e08514471896e3b3069cdc25f457036d257cc68.zip
Fix potential issues as found by coverity.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/addr.c2
-rw-r--r--src/libutil/diff.c7
-rw-r--r--src/libutil/fstring.c7
-rw-r--r--src/libutil/hash.c2
-rw-r--r--src/libutil/util.c12
5 files changed, 19 insertions, 11 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c
index a276f0cfd..cb044defa 100644
--- a/src/libutil/addr.c
+++ b/src/libutil/addr.c
@@ -63,7 +63,7 @@ rspamd_ip_check_ipv6 (void)
const struct in6_addr ip6_local = IN6ADDR_LOOPBACK_INIT;
s = socket (AF_INET6, SOCK_STREAM, 0);
- if (s == -1 && errno == EAFNOSUPPORT) {
+ if (s == -1) {
ipv6_status = RSPAMD_IPV6_UNSUPPORTED;
}
else {
diff --git a/src/libutil/diff.c b/src/libutil/diff.c
index 135c74624..1e6af6131 100644
--- a/src/libutil/diff.c
+++ b/src/libutil/diff.c
@@ -268,6 +268,9 @@ _ses (const void *a, gint aoff, gint n, const void *b, gint boff,
* - |
*/
+ /*
+ * XXX: coverity found this code suspicious, needs checking
+ */
if (m > n) {
if (x == u) {
_edit (ctx, DIFF_MATCH, aoff, n);
@@ -300,7 +303,6 @@ rspamd_diff (const void *a, gint aoff, gint n, const void *b, gint boff, gint m,
{
struct _ctx ctx;
gint d, x, y;
- struct diff_edit *e = NULL;
GArray *tmp;
tmp = g_array_sized_new (FALSE, TRUE, sizeof(gint), dmax);
@@ -327,9 +329,6 @@ rspamd_diff (const void *a, gint aoff, gint n, const void *b, gint boff, gint m,
g_array_free (tmp, TRUE);
return -1;
}
- if (ses && sn && e) {
- *sn = e->op ? ctx.si + 1 : 0;
- }
g_array_free (tmp, TRUE);
return d;
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c
index e45b0ded5..96c57131a 100644
--- a/src/libutil/fstring.c
+++ b/src/libutil/fstring.c
@@ -370,11 +370,12 @@ rspamd_fstrhash (rspamd_fstring_t * str)
{
size_t i;
guint32 hval;
- gchar *c = str->begin;
+ gchar *c;
if (str == NULL) {
return 0;
}
+ c = str->begin;
hval = str->len;
for (i = 0; i < str->len; i++, c++) {
@@ -391,13 +392,15 @@ rspamd_fstrhash_lc (rspamd_fstring_t * str, gboolean is_utf)
{
gsize i;
guint32 j, hval;
- const gchar *p = str->begin, *end = NULL;
+ const gchar *p, *end = NULL;
gchar t;
gunichar uc;
if (str == NULL) {
return 0;
}
+
+ p = str->begin;
hval = str->len;
if (is_utf) {
diff --git a/src/libutil/hash.c b/src/libutil/hash.c
index 05558078d..7610a4a9a 100644
--- a/src/libutil/hash.c
+++ b/src/libutil/hash.c
@@ -62,7 +62,7 @@ rspamd_lru_destroy_node (gpointer value)
if (elt->hash && elt->hash->value_destroy) {
elt->hash->value_destroy (elt->data);
}
- if (elt->link) {
+ if (elt->hash && elt->link) {
g_queue_delete_link (elt->hash->exp, elt->link);
}
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 9b9d17fb0..465dd92c6 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -129,7 +129,7 @@ static gint
rspamd_inet_socket_create (gint type, struct addrinfo *addr, gboolean is_server,
gboolean async, GList **list)
{
- gint fd, r, optlen, on = 1, s_error;
+ gint fd = -1, r, optlen, on = 1, s_error;
struct addrinfo *cur;
cur = addr;
@@ -425,7 +425,7 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
struct sockaddr_un un;
struct stat st;
struct addrinfo hints, *res;
- gint r, fd, serrno;
+ gint r, fd = -1, serrno;
gchar portbuf[8], **strv, **cur;
GList *result = NULL, *rcur;
@@ -486,9 +486,14 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
rspamd_snprintf (portbuf, sizeof (portbuf), "%d", (int)port);
if ((r = getaddrinfo (credits, portbuf, &hints, &res)) == 0) {
- r = rspamd_inet_socket_create (type, res, is_server, async, &result);
+ fd = rspamd_inet_socket_create (type, res, is_server, async, &result);
freeaddrinfo (res);
+
if (result == NULL) {
+ if (fd != -1) {
+ close (fd);
+ }
+
goto err;
}
}
@@ -499,6 +504,7 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
goto err;
}
}
+
cur++;
}