[tracker] libtracker-db: Fixed a crash in case reader_init didn't succeed
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-db: Fixed a crash in case reader_init didn't succeed
- Date: Fri, 15 Jan 2010 11:08:42 +0000 (UTC)
commit 1229c9ce499aed6a4a318a892e889d4fd47e9dc0
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Jan 15 12:06:55 2010 +0100
libtracker-db: Fixed a crash in case reader_init didn't succeed
src/libtracker-db/tracker-db-journal.c | 18 ++++++++++++++----
src/libtracker-db/tracker-db-manager.c | 2 --
2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index ad770b9..f23002b 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -661,13 +661,23 @@ gboolean
tracker_db_journal_reader_verify_last (GError **error)
{
guint32 entry_size_check;
+ gboolean success = FALSE;
- g_return_val_if_fail (reader.file != NULL, FALSE);
+ if (tracker_db_journal_reader_init (NULL)) {
+ entry_size_check = read_uint32 (reader.end - 4);
- entry_size_check = read_uint32 (reader.end - 4);
- reader.current = reader.end - entry_size_check;
+ if (reader.end - entry_size_check < reader.current) {
+ g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
+ "Damaged journal entry at end of journal");
+ return FALSE;
+ }
+
+ reader.current = reader.end - entry_size_check;
+ success = tracker_db_journal_reader_next (NULL);
+ tracker_db_journal_reader_shutdown ();
+ }
- return tracker_db_journal_reader_next (error);
+ return success;
}
gboolean
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 41933c3..62b9862 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -1271,9 +1271,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
/* Load databases */
g_message ("Loading databases files...");
- tracker_db_journal_reader_init (NULL);
must_recreate = !tracker_db_journal_reader_verify_last (NULL);
- tracker_db_journal_reader_shutdown ();
if (!must_recreate && g_file_test (in_use_filename, G_FILE_TEST_EXISTS)) {
gsize size = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]