Blame SOURCES/evolution-data-server-3.12.11-coverity-scan.patch

5e6360
diff -up evolution-data-server-3.12.11/addressbook/backends/google/e-book-backend-google.c.coverity-scan evolution-data-server-3.12.11/addressbook/backends/google/e-book-backend-google.c
5e6360
--- evolution-data-server-3.12.11/addressbook/backends/google/e-book-backend-google.c.coverity-scan	2015-05-28 19:51:23.209249835 +0200
5e6360
+++ evolution-data-server-3.12.11/addressbook/backends/google/e-book-backend-google.c	2015-05-28 19:51:29.810208047 +0200
5e6360
@@ -545,21 +545,15 @@ process_contact_finish (EBookBackend *ba
5e6360
                         GDataEntry *entry)
5e6360
 {
5e6360
 	EContact *new_contact;
5e6360
-	gboolean was_cached;
5e6360
 
5e6360
 	g_debug (G_STRFUNC);
5e6360
 
5e6360
-	was_cached = cache_has_contact (backend, gdata_entry_get_id (entry));
5e6360
 	new_contact = cache_add_contact (backend, entry);
5e6360
 
5e6360
 	if (!new_contact)
5e6360
 		return;
5e6360
 
5e6360
-	if (was_cached == TRUE) {
5e6360
-		e_book_backend_notify_update (backend, new_contact);
5e6360
-	} else {
5e6360
-		e_book_backend_notify_update (backend, new_contact);
5e6360
-	}
5e6360
+	e_book_backend_notify_update (backend, new_contact);
5e6360
 
5e6360
 	g_object_unref (new_contact);
5e6360
 }
5e6360
diff -up evolution-data-server-3.12.11/addressbook/libebook-contacts/e-vcard.c.coverity-scan evolution-data-server-3.12.11/addressbook/libebook-contacts/e-vcard.c
5e6360
--- evolution-data-server-3.12.11/addressbook/libebook-contacts/e-vcard.c.coverity-scan	2014-04-23 14:37:03.000000000 +0200
5e6360
+++ evolution-data-server-3.12.11/addressbook/libebook-contacts/e-vcard.c	2015-05-28 19:50:57.068415329 +0200
5e6360
@@ -1337,7 +1337,7 @@ e_vcard_to_string_vcard_30 (EVCard *evc)
5e6360
 					gchar *value = v->data;
5e6360
 					gchar *pval = value;
5e6360
 					gboolean quotes = FALSE;
5e6360
-					while (*pval) {
5e6360
+					while (pval && *pval) {
5e6360
 						if (!g_unichar_isalnum (g_utf8_get_char (pval))) {
5e6360
 							quotes = TRUE;
5e6360
 							break;
5e6360
diff -up evolution-data-server-3.12.11/addressbook/libedata-book/e-book-sqlite.c.coverity-scan evolution-data-server-3.12.11/addressbook/libedata-book/e-book-sqlite.c
5e6360
--- evolution-data-server-3.12.11/addressbook/libedata-book/e-book-sqlite.c.coverity-scan	2015-05-28 19:50:57.061415373 +0200
5e6360
+++ evolution-data-server-3.12.11/addressbook/libedata-book/e-book-sqlite.c	2015-05-28 19:50:57.069415323 +0200
5e6360
@@ -2749,7 +2749,7 @@ ebsql_init_legacy_keys (EBookSqlite *ebs
5e6360
 		}
5e6360
 
5e6360
 		/* Repeat for 'sync_data' */
5e6360
-		success = ebsql_exec_printf (
5e6360
+		success = success && ebsql_exec_printf (
5e6360
 			ebsql, "SELECT sync_data FROM folders WHERE folder_id = %Q",
5e6360
 			get_string_cb, &sync_data, NULL, error, ebsql->priv->folderid);
5e6360
 
5e6360
@@ -5265,6 +5265,7 @@ ebsql_generate_constraints (EBookSqlite
5e6360
 		g_warn_if_fail (test->field != NULL);
5e6360
 
5e6360
 		/* Generate the field test */
5e6360
+		/* coverity[var_deref_op] */
5e6360
 		generate_test_func (ebsql, string, test);
5e6360
 	}
5e6360
 
5e6360
diff -up evolution-data-server-3.12.11/addressbook/libedata-book/e-data-book-cursor.c.coverity-scan evolution-data-server-3.12.11/addressbook/libedata-book/e-data-book-cursor.c
5e6360
--- evolution-data-server-3.12.11/addressbook/libedata-book/e-data-book-cursor.c.coverity-scan	2014-03-24 10:07:52.000000000 +0100
5e6360
+++ evolution-data-server-3.12.11/addressbook/libedata-book/e-data-book-cursor.c	2015-05-28 19:50:57.069415323 +0200
5e6360
@@ -499,9 +499,13 @@ calculate_step_position (EDataBookCursor
5e6360
                          gint results)
5e6360
 {
5e6360
 	EDataBookCursorPrivate *priv = cursor->priv;
5e6360
-	gint new_position = priv->position;
5e6360
+	gint new_position;
5e6360
 	gint offset = results;
5e6360
 
5e6360
+	g_return_if_fail (origin == E_BOOK_CURSOR_ORIGIN_CURRENT ||
5e6360
+			  origin == E_BOOK_CURSOR_ORIGIN_BEGIN ||
5e6360
+			  origin == E_BOOK_CURSOR_ORIGIN_END);
5e6360
+
5e6360
 	/* If we didnt get as many contacts as asked for, it indicates that
5e6360
 	 * we've reached the end of the list (or beginning)... in this case
5e6360
 	 * we add 1 to the offset
5e6360
diff -up evolution-data-server-3.12.11/calendar/libedata-cal/e-cal-backend-intervaltree.c.coverity-scan evolution-data-server-3.12.11/calendar/libedata-cal/e-cal-backend-intervaltree.c
5e6360
--- evolution-data-server-3.12.11/calendar/libedata-cal/e-cal-backend-intervaltree.c.coverity-scan	2014-03-24 10:07:52.000000000 +0100
5e6360
+++ evolution-data-server-3.12.11/calendar/libedata-cal/e-cal-backend-intervaltree.c	2015-05-28 19:50:57.069415323 +0200
5e6360
@@ -229,7 +229,7 @@ static void
5e6360
 fixup_min_max_fields (EIntervalTree *tree,
5e6360
                       EIntervalNode *node)
5e6360
 {
5e6360
-	while (node != tree->priv->root) {
5e6360
+	while (node && node != tree->priv->root) {
5e6360
 		node->max = MAX (node->end, MAX (node->left->max, node->right->max));
5e6360
 		node->min = MIN (node->start, node->left->min);
5e6360
 
5e6360
@@ -320,6 +320,9 @@ intervaltree_fixup_deletion (EIntervalTr
5e6360
 	EIntervalNode *w;
5e6360
 
5e6360
 	while ((!x->red) && (root != x)) {
5e6360
+		if (!x->parent)
5e6360
+			break;
5e6360
+
5e6360
 		if (x == x->parent->left) {
5e6360
 			w = x->parent->right;
5e6360
 
5e6360
diff -up evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-server.c.coverity-scan evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-server.c
5e6360
--- evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-server.c.coverity-scan	2015-05-28 19:50:57.065415348 +0200
5e6360
+++ evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-server.c	2015-05-28 19:50:57.070415316 +0200
5e6360
@@ -1244,6 +1244,7 @@ imapx_command_start (CamelIMAPXServer *i
5e6360
 	GCancellable *cancellable = NULL;
5e6360
 	gboolean cp_continuation;
5e6360
 	gboolean cp_literal_plus;
5e6360
+	gboolean success;
5e6360
 	GList *head;
5e6360
 	gchar *string;
5e6360
 	GError *local_error = NULL;
5e6360
@@ -1309,13 +1310,13 @@ imapx_command_start (CamelIMAPXServer *i
5e6360
 	string = g_strdup_printf (
5e6360
 		"%c%05u %s\r\n", is->tagprefix, ic->tag, cp->data);
5e6360
 	g_mutex_lock (&is->priv->stream_lock);
5e6360
-	g_output_stream_write_all (
5e6360
+	success = g_output_stream_write_all (
5e6360
 		output_stream, string, strlen (string),
5e6360
 		NULL, cancellable, &local_error);
5e6360
 	g_mutex_unlock (&is->priv->stream_lock);
5e6360
 	g_free (string);
5e6360
 
5e6360
-	if (local_error != NULL)
5e6360
+	if (local_error != NULL || !success)
5e6360
 		goto fail;
5e6360
 
5e6360
 	while (is->literal == ic && cp_literal_plus) {
5e6360
@@ -1345,7 +1346,7 @@ fail:
5e6360
 	if (ic->complete != NULL)
5e6360
 		ic->complete (is, ic);
5e6360
 
5e6360
-	g_error_free (local_error);
5e6360
+	g_clear_error (&local_error);
5e6360
 
5e6360
 exit:
5e6360
 	g_clear_object (&input_stream);
5e6360
@@ -4307,7 +4308,9 @@ imapx_server_set_streams (CamelIMAPXServ
5e6360
 static void
5e6360
 imapx_server_child_process_setup (gpointer user_data)
5e6360
 {
5e6360
+#ifdef TIOCNOTTY
5e6360
 	gint fd;
5e6360
+#endif /* TIOCNOTTY */
5e6360
 
5e6360
 	setsid ();
5e6360
 
5e6360
@@ -4586,6 +4589,7 @@ connected:
5e6360
 
5e6360
 		input_stream = camel_imapx_server_ref_input_stream (is);
5e6360
 
5e6360
+		token = NULL;
5e6360
 		tok = camel_imapx_input_stream_token (
5e6360
 			CAMEL_IMAPX_INPUT_STREAM (input_stream),
5e6360
 			&token, &len, cancellable, error);
5e6360
diff -up evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-store-summary.c.coverity-scan evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-store-summary.c
5e6360
--- evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-store-summary.c.coverity-scan	2014-05-22 08:45:46.000000000 +0200
5e6360
+++ evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-store-summary.c	2015-05-28 19:50:57.071415310 +0200
5e6360
@@ -187,6 +187,7 @@ imapx_store_summary_store_info_load (Cam
5e6360
 
5e6360
 	if (camel_file_util_decode_string (in, &mailbox_name) == -1) {
5e6360
 		camel_store_summary_info_unref (summary, si);
5e6360
+		g_free (separator);
5e6360
 		return NULL;
5e6360
 	}
5e6360
 
5e6360
diff -up evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-utils.c.coverity-scan evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-utils.c
5e6360
--- evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-utils.c.coverity-scan	2014-11-21 12:38:16.000000000 +0100
5e6360
+++ evolution-data-server-3.12.11/camel/providers/imapx/camel-imapx-utils.c	2015-05-28 19:50:57.071415310 +0200
5e6360
@@ -841,8 +841,17 @@ imapx_parse_ext_optional (CamelIMAPXInpu
5e6360
 			dinfo = g_malloc0 (sizeof (*dinfo));
5e6360
 			dinfo->refcount = 1;
5e6360
 			/* should be string */
5e6360
-			camel_imapx_input_stream_astring (
5e6360
-				stream, &token, cancellable, NULL);
5e6360
+			if (!camel_imapx_input_stream_astring (stream, &token, cancellable, &local_error)) {
5e6360
+				camel_content_disposition_unref (dinfo);
5e6360
+				if (!local_error)
5e6360
+					g_set_error (
5e6360
+						&local_error,
5e6360
+						CAMEL_IMAPX_ERROR, 1,
5e6360
+						"expecting string");
5e6360
+				g_propagate_error (error, local_error);
5e6360
+
5e6360
+				return NULL;
5e6360
+			}
5e6360
 
5e6360
 			dinfo->disposition = g_strdup ((gchar *) token);
5e6360
 			imapx_parse_param_list (
5e6360
@@ -1039,14 +1048,20 @@ imapx_parse_address_list (CamelIMAPXInpu
5e6360
 			addr = camel_header_address_new ();
5e6360
 			addr->type = CAMEL_HEADER_ADDRESS_NAME;
5e6360
 			camel_imapx_input_stream_nstring (stream, &token, cancellable, &local_error);
5e6360
-			if (local_error)
5e6360
+			if (local_error) {
5e6360
+				camel_header_address_unref (addr);
5e6360
 				goto error;
5e6360
+			}
5e6360
 
5e6360
 			addr->name = g_strdup ((gchar *) token);
5e6360
 			/* we ignore the route, nobody uses it in the real world */
5e6360
 			camel_imapx_input_stream_nstring (stream, &token, cancellable, &local_error);
5e6360
-			if (local_error)
5e6360
+			if (local_error) {
5e6360
+				camel_header_address_unref (addr);
5e6360
 				goto error;
5e6360
+			}
5e6360
+
5e6360
+			mbox = NULL;
5e6360
 
5e6360
 			/* [RFC-822] group syntax is indicated by a special
5e6360
 			 * form of address structure in which the host name
5e6360
@@ -1057,18 +1072,23 @@ imapx_parse_address_list (CamelIMAPXInpu
5e6360
 			 * mailbox name field holds the group name phrase. */
5e6360
 
5e6360
 			camel_imapx_input_stream_nstring (stream, (guchar **) &mbox, cancellable, &local_error);
5e6360
-			if (local_error)
5e6360
+			if (local_error) {
5e6360
+				camel_header_address_unref (addr);
5e6360
 				goto error;
5e6360
+			}
5e6360
 
5e6360
 			mbox = g_strdup (mbox);
5e6360
 
5e6360
 			camel_imapx_input_stream_nstring (stream, &host, cancellable, &local_error);
5e6360
-			if (local_error)
5e6360
+			if (local_error) {
5e6360
+				camel_header_address_unref (addr);
5e6360
 				goto error;
5e6360
+			}
5e6360
 
5e6360
 			if (host == NULL) {
5e6360
 				if (mbox == NULL) {
5e6360
 					group = NULL;
5e6360
+					camel_header_address_unref (addr);
5e6360
 				} else {
5e6360
 					g_free (addr->name);
5e6360
 					addr->name = mbox;
5e6360
@@ -1319,10 +1339,7 @@ imapx_parse_body (CamelIMAPXInputStream
5e6360
 				stream, tok, token, len);
5e6360
 		} while (tok == '(');
5e6360
 
5e6360
-		camel_imapx_input_stream_astring (
5e6360
-			stream, &token, cancellable, &local_error);
5e6360
-
5e6360
-		if (local_error)
5e6360
+		if (!camel_imapx_input_stream_astring (stream, &token, cancellable, &local_error) || local_error)
5e6360
 			goto error;
5e6360
 
5e6360
 		cinfo->type = camel_content_type_new (
5e6360
diff -up evolution-data-server-3.12.11/camel/providers/pop3/camel-pop3-store.c.coverity-scan evolution-data-server-3.12.11/camel/providers/pop3/camel-pop3-store.c
5e6360
--- evolution-data-server-3.12.11/camel/providers/pop3/camel-pop3-store.c.coverity-scan	2014-11-21 12:38:16.000000000 +0100
5e6360
+++ evolution-data-server-3.12.11/camel/providers/pop3/camel-pop3-store.c	2015-05-28 19:50:57.071415310 +0200
5e6360
@@ -343,10 +343,10 @@ try_sasl (CamelPOP3Store *store,
5e6360
 		if (strncmp ((gchar *) line, "+ ", 2) != 0
5e6360
 		    || camel_sasl_get_authenticated (sasl)
5e6360
 		    || (resp = (guchar *) camel_sasl_challenge_base64_sync (sasl, (const gchar *) line + 2, cancellable, &local_error)) == NULL) {
5e6360
-			camel_stream_write_string (
5e6360
-				CAMEL_STREAM (pop3_stream), "*\r\n", cancellable, NULL);
5e6360
-			/* coverity[unchecked_value] */
5e6360
-			camel_pop3_stream_line (pop3_stream, &line, &len, cancellable, NULL);
5e6360
+			if (camel_stream_write_string (CAMEL_STREAM (pop3_stream), "*\r\n", cancellable, NULL)) {
5e6360
+				/* coverity[unchecked_value] */
5e6360
+				camel_pop3_stream_line (pop3_stream, &line, &len, cancellable, NULL);
5e6360
+			}
5e6360
 
5e6360
 			if (local_error) {
5e6360
 				g_propagate_error (error, local_error);
5e6360
diff -up evolution-data-server-3.12.11/tests/test-server-utils/e-test-server-utils.c.coverity-scan evolution-data-server-3.12.11/tests/test-server-utils/e-test-server-utils.c
5e6360
--- evolution-data-server-3.12.11/tests/test-server-utils/e-test-server-utils.c.coverity-scan	2014-06-01 21:10:19.000000000 +0200
5e6360
+++ evolution-data-server-3.12.11/tests/test-server-utils/e-test-server-utils.c	2015-05-28 19:50:57.071415310 +0200
5e6360
@@ -375,7 +375,7 @@ e_test_server_utils_source_added (ESourc
5e6360
 
5e6360
 		if (!pair->closure->use_async_connect &&
5e6360
 		    !pair->fixture->service.book_client)
5e6360
-			g_error ("Unable to create the test book: %s", error->message);
5e6360
+			g_error ("Unable to create the test book: %s", error ? error->message : "Unknown error");
5e6360
 
5e6360
 		break;
5e6360