From 82f7125f45269be8d2cded86d8c7fe37bd0364dc Mon Sep 17 00:00:00 2001 From: Suman Manjunath Date: Sun, 6 Jan 2008 16:43:58 +0000 Subject: Patch from Christian Krause : Fix for bug #506772 (Not-NULL check for a string array before finding its length), handle NULL filename strings before backup/restore/check operations in the backup-restore plugin. svn path=/trunk/; revision=34768 --- addressbook/ChangeLog | 7 ++++ addressbook/tools/evolution-addressbook-export.c | 2 +- plugins/backup-restore/ChangeLog | 6 +++ plugins/backup-restore/backup.c | 47 +++++++++++++----------- plugins/google-account-setup/ChangeLog | 2 +- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 3abca21cf5..f3bf0ae114 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,10 @@ +2008-01-06 Christian Krause + + ** Fix for bug #506772 + + * tools/evolution-addressbook-export.c: (main): Not-NULL check for a + string array before finding its length. + 2007-12-11 Sankar P ** Fix for bug #501969 diff --git a/addressbook/tools/evolution-addressbook-export.c b/addressbook/tools/evolution-addressbook-export.c index 92f05664d1..ec05a1da63 100644 --- a/addressbook/tools/evolution-addressbook-export.c +++ b/addressbook/tools/evolution-addressbook-export.c @@ -92,7 +92,7 @@ main (int argc, char **argv) GNOME_PARAM_NONE); /* Parsing Parameter */ - if (g_strv_length (opt_remaining) > 0) + if (opt_remaining && g_strv_length (opt_remaining) > 0) opt_addressbook_folder_uri = g_strdup (opt_remaining[0]); if (opt_list_folders_mode != FALSE) { diff --git a/plugins/backup-restore/ChangeLog b/plugins/backup-restore/ChangeLog index 94cbeb44e6..13f250e5b5 100644 --- a/plugins/backup-restore/ChangeLog +++ b/plugins/backup-restore/ChangeLog @@ -1,3 +1,9 @@ +2008-01-06 Christian Krause + + * backup.c: (backup), (restore), (check), (main): Initialize static + variables before use, not-NULL checks for filename before + backup/restore/check operations. + 2007-08-07 Johnny Jacob * Committed on behalf of Anand V M diff --git a/plugins/backup-restore/backup.c b/plugins/backup-restore/backup.c index ec3e0b16be..6c19871d4c 100644 --- a/plugins/backup-restore/backup.c +++ b/plugins/backup-restore/backup.c @@ -21,11 +21,11 @@ #define ARCHIVE_NAME "evolution-backup.tar.gz" static gboolean backup_op = FALSE; -static char *bk_file; +static char *bk_file = NULL; static gboolean restore_op = FALSE; -static char *res_file; +static char *res_file = NULL; static gboolean check_op = FALSE; -static char *chk_file; +static char *chk_file = NULL; static gboolean restart_arg = FALSE; static gboolean gui_arg = FALSE; static gchar **opt_remaining = NULL; @@ -63,6 +63,8 @@ backup (const char *filename) { char *command; + g_return_if_fail (filename && *filename); + CANCEL (complete); txt = _("Shutting down Evolution"); /* FIXME Will the versioned setting always work? */ @@ -72,7 +74,6 @@ backup (const char *filename) txt = _("Backing Evolution accounts and settings"); s ("gconftool-2 --dump " GCONF_DIR " > " GCONF_DUMP_PATH); - CANCEL (complete); txt = _("Backing Evolution data (Mails, Contacts, Calendar, Tasks, Memos)"); @@ -102,6 +103,8 @@ restore (const char *filename) { char *command; + g_return_if_fail (filename && *filename); + /* FIXME Will the versioned setting always work? */ CANCEL (complete); txt = _("Shutting down Evolution"); @@ -142,6 +145,8 @@ check (const char *filename) { char *command; + g_return_if_fail (filename && *filename); + command = g_strdup_printf ("tar ztf %s | grep -e \"^\\.evolution/$\"", filename); result = system (command); g_free (command); @@ -238,21 +243,22 @@ main (int argc, char **argv) GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_NONE); - - for (i = 0; i < g_strv_length (opt_remaining); i++) { - if (backup_op) { - oper = _("Backing up to the folder %s"); - d(g_message ("Backing up to the folder %s", (char *) opt_remaining[i])); - bk_file = g_strdup ((char *) opt_remaining[i]); - file = bk_file; - } else if (restore_op) { - oper = _("Restoring from the folder %s"); - d(g_message ("Restoring from the folder %s", (char *) opt_remaining[i])); - res_file = g_strdup ((char *) opt_remaining[i]); - file = res_file; - } else if (check_op) { - d(g_message ("Checking %s", (char *) opt_remaining[i])); - chk_file = g_strdup ((char *) opt_remaining[i]); + if (opt_remaining) { + for (i = 0; i < g_strv_length (opt_remaining); i++) { + if (backup_op) { + oper = _("Backing up to the folder %s"); + d(g_message ("Backing up to the folder %s", (char *) opt_remaining[i])); + bk_file = g_strdup ((char *) opt_remaining[i]); + file = bk_file; + } else if (restore_op) { + oper = _("Restoring from the folder %s"); + d(g_message ("Restoring from the folder %s", (char *) opt_remaining[i])); + res_file = g_strdup ((char *) opt_remaining[i]); + file = res_file; + } else if (check_op) { + d(g_message ("Checking %s", (char *) opt_remaining[i])); + chk_file = g_strdup ((char *) opt_remaining[i]); + } } } @@ -267,6 +273,7 @@ main (int argc, char **argv) GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + if (oper && file) str = g_strdup_printf(oper, file); @@ -282,8 +289,6 @@ main (int argc, char **argv) pbar = gtk_progress_bar_new (); gtk_box_pack_start ((GtkBox *)hbox, pbar, TRUE, TRUE, 6); - - gtk_box_pack_start ((GtkBox *)vbox, hbox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(progress_dialog)->vbox), vbox); diff --git a/plugins/google-account-setup/ChangeLog b/plugins/google-account-setup/ChangeLog index 91381d897d..63dcef3a7f 100644 --- a/plugins/google-account-setup/ChangeLog +++ b/plugins/google-account-setup/ChangeLog @@ -1,4 +1,4 @@ -2007-12-23 Nyall +2007-12-23 Nyall Dawson ** Fix for bug #503954 -- cgit