[tracker/binary-log-2: 12/35] libtracker-db: Fix CRC check in journal reader
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/binary-log-2: 12/35] libtracker-db: Fix CRC check in journal reader
- Date: Tue, 12 Jan 2010 14:49:09 +0000 (UTC)
commit 39c3a4d9e3401e56cb967278fa4433a7fa43210e
Author: Jürg Billeter <j bitron ch>
Date: Wed Jan 6 10:40:48 2010 +0000
libtracker-db: Fix CRC check in journal reader
src/libtracker-db/tracker-db-journal.c | 20 ++++++++++++++------
1 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 5e16f6d..dcd67d3 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -649,7 +649,8 @@ tracker_db_journal_reader_next (GError **error)
/* Expect new transaction or end of file */
guint32 entry_size;
guint32 entry_size_check;
- guint32 crc32;
+ guint32 crc;
+ guint32 crc_check;
/* Check the end is not before where we currently are */
if (reader.current >= reader.end) {
@@ -689,7 +690,7 @@ tracker_db_journal_reader_next (GError **error)
*/
reader.current += 4;
- /* compare with entry_size at end */
+ /* Read entry size check at the end of the entry */
entry_size_check = read_uint32 (reader.entry_end - 4);
if (entry_size != entry_size_check) {
@@ -701,17 +702,24 @@ tracker_db_journal_reader_next (GError **error)
return FALSE;
}
+ /* Read the amount of triples */
reader.amount_of_triples = read_uint32 (reader.current);
reader.current += 4;
- crc32 = read_uint32 (reader.current);
+ /* Read the crc */
+ crc_check = read_uint32 (reader.current);
reader.current += 4;
- /* verify checksum */
- if (crc32 != tracker_crc32 (reader.entry_begin, entry_size)) {
+ /* Calculate the crc */
+ crc = tracker_crc32 (reader.entry_begin + (sizeof (guint32) * 3), entry_size - (sizeof (guint32) * 3));
+
+ /* Verify checksum */
+ if (crc != crc_check) {
/* damaged journal entry */
g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0,
- "Damaged journal entry, crc32 failed");
+ "Damaged journal entry, 0x%.8x != 0x%.8x (crc32 failed)",
+ crc,
+ crc_check);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]