corrupted db files?
Fletcher Mattox
fletcher at cs.utexas.edu
Wed Jan 1 00:23:26 CET 2003
It looks like bogoutil doesn't swap bytes before printing the token's value.
You'll probably want to do this more cleanly, but this works for me.
Index: bogoutil.c
===================================================================
RCS file: /lusr/share/cvsroot/bogofilter/bogoutil.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 bogoutil.c
--- bogoutil.c 14 Dec 2002 02:58:37 -0000 1.1.1.1
+++ bogoutil.c 31 Dec 2002 23:05:28 -0000
@@ -66,10 +66,14 @@
rv = 2;
}
else {
+ unsigned long value;
for (;;) {
ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT);
+ value = *(unsigned long *)data.data;
if (ret == 0) {
- printf("%.*s %lu\n", (int)key.size, (char *) key.data, *(unsigned long *) data.data);
+ if (dbh->is_swapped)
+ value = swap_long(value);
+ printf("%.*s %lu\n", (int)key.size, (char *) key.data, value);
}
else if (ret == DB_NOTFOUND) {
break;
Index: datastore_db.c
===================================================================
RCS file: /lusr/share/cvsroot/bogofilter/datastore_db.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 datastore_db.c
--- datastore_db.c 14 Dec 2002 02:58:37 -0000 1.1.1.1
+++ datastore_db.c 31 Dec 2002 22:44:13 -0000
@@ -46,7 +46,7 @@
}
/* stolen from glibc's byteswap.c */
-static long swap_long(long x){
+long swap_long(long x){
return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24));
}
More information about the Bogofilter
mailing list