evolution-data-server r9627 - in branches/gnome-2-24/addressbook: . backends/file backends/groupwise libedata-book
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9627 - in branches/gnome-2-24/addressbook: . backends/file backends/groupwise libedata-book
- Date: Mon, 29 Sep 2008 09:22:29 +0000 (UTC)
Author: mcrha
Date: Mon Sep 29 09:22:29 2008
New Revision: 9627
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9627&view=rev
Log:
2008-09-29 Milan Crha <mcrha redhat com>
** Part of fix for bug #497928
* backends/file/e-book-backend-file.c: (build_summary),
(e_book_backend_file_get_contact_list), (book_view_thread),
(e_book_backend_file_load_source): Check for NULL pointers
and errors on opening an address book to prevent crash.
* backends/groupwise/e-book-backend-groupwise.c:
(e_book_backend_groupwise_get_contact_list), (book_view_thread):
Check for NULL pointers and free allocated memory properly.
* libedata-book/e-book-backend-summary.c:
(e_book_backend_summary_add_contact), (e_book_backend_summary_search),
(e_book_backend_summary_remove_contact), (e_book_backend_summary_save),
(e_book_backend_summary_check_contact), (e_book_backend_summary_touch),
(e_book_backend_summary_is_up_to_date), (e_book_backend_summary_load),
(e_book_backend_summary_is_summary_query),
(e_book_backend_summary_get_summary_vcard):
Check for NULL pointers before accessing members of the structure.
Modified:
branches/gnome-2-24/addressbook/ChangeLog
branches/gnome-2-24/addressbook/backends/file/e-book-backend-file.c
branches/gnome-2-24/addressbook/backends/groupwise/e-book-backend-groupwise.c
branches/gnome-2-24/addressbook/libedata-book/e-book-backend-summary.c
Modified: branches/gnome-2-24/addressbook/backends/file/e-book-backend-file.c
==============================================================================
--- branches/gnome-2-24/addressbook/backends/file/e-book-backend-file.c (original)
+++ branches/gnome-2-24/addressbook/backends/file/e-book-backend-file.c Mon Sep 29 09:22:29 2008
@@ -121,7 +121,7 @@
return contact;
}
-static void
+static gboolean
build_summary (EBookBackendFilePrivate *bfpriv)
{
DB *db = bfpriv->file_db;
@@ -133,7 +133,7 @@
if (db_error != 0) {
g_warning (G_STRLOC ": db->cursor failed with %s", db_strerror (db_error));
- return;
+ return FALSE;
}
memset (&vcard_dbt, 0, sizeof (vcard_dbt));
@@ -155,6 +155,8 @@
}
dbc->c_close (dbc);
+
+ return TRUE;
}
static char *
@@ -412,6 +414,9 @@
GPtrArray *ids = e_book_backend_summary_search (bf->priv->summary, search);
int i;
+ if (!ids)
+ return GNOME_Evolution_Addressbook_ContactNotFound;
+
for (i = 0; i < ids->len; i ++) {
char *id = g_ptr_array_index (ids, i);
string_to_dbt (id, &id_dbt);
@@ -567,6 +572,9 @@
GPtrArray *ids = e_book_backend_summary_search (bf->priv->summary, e_data_book_view_get_card_query (book_view));
int i;
+ if (!ids)
+ goto done;
+
for (i = 0; i < ids->len; i ++) {
char *id = g_ptr_array_index (ids, i);
@@ -632,7 +640,7 @@
}
-
+done:
if (e_flag_is_set (closure->running))
e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
@@ -1249,7 +1257,10 @@
if (e_book_backend_summary_is_up_to_date (bf->priv->summary, db_mtime) == FALSE
|| e_book_backend_summary_load (bf->priv->summary) == FALSE ) {
- build_summary (bf->priv);
+ if (!bf->priv->summary || !build_summary (bf->priv)) {
+ g_warning ("Failed to build summary for an address book %s", bf->priv->filename);
+ return GNOME_Evolution_Addressbook_OtherError;
+ }
}
e_book_backend_set_is_loaded (backend, TRUE);
Modified: branches/gnome-2-24/addressbook/backends/groupwise/e-book-backend-groupwise.c
==============================================================================
--- branches/gnome-2-24/addressbook/backends/groupwise/e-book-backend-groupwise.c (original)
+++ branches/gnome-2-24/addressbook/backends/groupwise/e-book-backend-groupwise.c Mon Sep 29 09:22:29 2008
@@ -1961,6 +1961,9 @@
e_book_backend_summary_is_summary_query (egwb->priv->summary, query)) {
int i;
ids = e_book_backend_summary_search (egwb->priv->summary, query);
+ if (!ids)
+ return;
+
for (i = 0; i < ids->len; i ++) {
char *uid = g_ptr_array_index (ids, i);
@@ -2024,7 +2027,7 @@
ids = e_book_backend_db_cache_search (egwb->priv->file_db, query);
}
- if (ids->len > 0) {
+ if (ids && ids->len > 0) {
status = e_gw_connection_get_items_from_ids (egwb->priv->cnc,
egwb->priv->container_id,
"name email default members",
@@ -2034,8 +2037,9 @@
egwb->priv->container_id,
"name email default members",
ids, &gw_items);
- g_ptr_array_free (ids, TRUE);
}
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
match_needed = FALSE;
} else {
if (strcmp (query, "(contains \"x-evolution-any-field\" \"\")") != 0)
@@ -2197,8 +2201,9 @@
ids = e_book_backend_summary_search (gwb->priv->summary, query);
if (ids && ids->len > 0) {
get_contacts_from_cache (gwb, query, ids, book_view, closure);
- g_ptr_array_free (ids, TRUE);
}
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
bonobo_object_unref (book_view);
return NULL;
}
@@ -2323,7 +2328,6 @@
if (enable_debug && status == E_GW_CONNECTION_STATUS_OK)
printf ("read contacts from server \n");
}
- g_ptr_array_free (ids, TRUE);
}
else {
if (gwb->priv->is_cache_ready) {
@@ -2347,6 +2351,9 @@
if (filter)
g_object_unref (filter);
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
+
return NULL;
}
@@ -2368,6 +2375,9 @@
view, filter, &gw_items);
}
+ if (ids)
+ g_ptr_array_free (ids, TRUE);
+
if (status != E_GW_CONNECTION_STATUS_OK) {
e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_OtherError);
bonobo_object_unref (book_view);
Modified: branches/gnome-2-24/addressbook/libedata-book/e-book-backend-summary.c
==============================================================================
--- branches/gnome-2-24/addressbook/libedata-book/e-book-backend-summary.c (original)
+++ branches/gnome-2-24/addressbook/libedata-book/e-book-backend-summary.c Mon Sep 29 09:22:29 2008
@@ -531,6 +531,8 @@
EBookBackendSummaryItem *new_item;
int i;
+ g_return_val_if_fail (summary != NULL, FALSE);
+
clear_items (summary);
if (!e_book_backend_summary_open (summary))
@@ -684,6 +686,8 @@
char *new_filename = NULL;
int i;
+ g_return_val_if_fail (summary != NULL, FALSE);
+
if (!summary->priv->dirty)
return TRUE;
@@ -761,6 +765,8 @@
EBookBackendSummaryItem *new_item;
char *id = NULL;
+ g_return_if_fail (summary != NULL);
+
/* ID normally should not be NULL for a contact. */
/* Added this check as groupwise server sometimes returns
* contacts with NULL id
@@ -820,7 +826,11 @@
void
e_book_backend_summary_remove_contact (EBookBackendSummary *summary, const char *id)
{
- EBookBackendSummaryItem *item = g_hash_table_lookup (summary->priv->id_to_item, id);
+ EBookBackendSummaryItem *item;
+
+ g_return_if_fail (summary != NULL);
+
+ item = g_hash_table_lookup (summary->priv->id_to_item, id);
if (item) {
g_ptr_array_remove (summary->priv->items, item);
@@ -846,6 +856,8 @@
gboolean
e_book_backend_summary_check_contact (EBookBackendSummary *summary, const char *id)
{
+ g_return_val_if_fail (summary != NULL, FALSE);
+
return g_hash_table_lookup (summary->priv->id_to_item, id) != NULL;
}
@@ -884,6 +896,8 @@
void
e_book_backend_summary_touch (EBookBackendSummary *summary)
{
+ g_return_if_fail (summary != NULL);
+
summary->priv->dirty = TRUE;
if (!summary->priv->flush_timeout
&& summary->priv->flush_timeout_millis)
@@ -903,6 +917,8 @@
gboolean
e_book_backend_summary_is_up_to_date (EBookBackendSummary *summary, time_t t)
{
+ g_return_val_if_fail (summary != NULL, FALSE);
+
if (!e_book_backend_summary_open (summary))
return FALSE;
else
@@ -970,6 +986,8 @@
int i;
int esexp_error;
+ g_return_val_if_fail (summary != NULL, FALSE);
+
sexp = e_sexp_new();
for(i=0;i<sizeof(check_symbols)/sizeof(check_symbols[0]);i++) {
@@ -1148,10 +1166,12 @@
{
ESExp *sexp;
ESExpResult *r;
- GPtrArray *retval = g_ptr_array_new();
+ GPtrArray *retval;
int i;
int esexp_error;
+ g_return_val_if_fail (summary != NULL, NULL);
+
sexp = e_sexp_new();
for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) {
@@ -1171,6 +1191,7 @@
return NULL;
}
+ retval = g_ptr_array_new ();
r = e_sexp_eval(sexp);
if (r && r->type == ESEXP_RES_ARRAY_PTR && r->value.ptrarray) {
@@ -1201,7 +1222,11 @@
char*
e_book_backend_summary_get_summary_vcard(EBookBackendSummary *summary, const char *id)
{
- EBookBackendSummaryItem *item = g_hash_table_lookup (summary->priv->id_to_item, id);
+ EBookBackendSummaryItem *item;
+
+ g_return_val_if_fail (summary != NULL, NULL);
+
+ item = g_hash_table_lookup (summary->priv->id_to_item, id);
if (item) {
EContact *contact = e_contact_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]