[tracker/binary-log] Don't include the header in the CRC



commit 18145eb7f78c903c66d2f3d0e0ca332ee924ca1e
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Dec 30 15:25:38 2009 +0100

    Don't include the header in the CRC

 src/libtracker-db/tracker-db-journal.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 8325854..49f61df 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -153,7 +153,9 @@ tracker_db_journal_start_transaction (void)
 
 	cur_block_maybe_expand (size);
 
-	/* Leave space for size, amount and crc */
+	/* Leave space for size, amount and crc 
+	 * Check and keep in sync the offset variable at 
+	 * tracker_db_journal_commit_transaction too */
 
 	memset (cur_block, 0, size);
 
@@ -289,6 +291,7 @@ tracker_db_journal_commit_transaction (void)
 	guint32 crc;
 	guint begin_pos = 0;
 	guint size = sizeof (guint32);
+	guint offset = sizeof(guint32) * 3;
 
 	g_assert (journal);
 
@@ -303,7 +306,7 @@ tracker_db_journal_commit_transaction (void)
 
 	/* CRC is calculated with CRC's own bytes set to zeroes */
 
-	crc = tracker_crc32 (cur_block, cur_block_len);
+	crc = tracker_crc32 (cur_block + offset, cur_block_len - offset);
 	cur_setnum (cur_block, &begin_pos, crc);
 
 	write (fileno (journal), cur_block, cur_block_len);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]