[tracker/binary-log-2: 14/63] libtracker-db: Don't include the header in the CRC



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

    libtracker-db: Don't include the header in the CRC

 src/libtracker-db/tracker-db-journal.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 8325854..6ede989 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <stdio.h>
-#include <string.h>
+#include <string.h>/query
 #include <sys/stat.h>
 #include <unistd.h>
 
@@ -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);
 
@@ -301,9 +304,9 @@ tracker_db_journal_commit_transaction (void)
 
 	cur_block_len += size;
 
-	/* CRC is calculated with CRC's own bytes set to zeroes */
+	/* CRC is calculated from entries until appended amount int */
 
-	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]