tdb: fix recovery reuse after crash
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Apr 2010 04:23:41 +0000 (13:53 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Apr 2010 04:23:41 +0000 (13:53 +0930)
commit8c8782ecbb347e026f67d82a39555c0e43b1e9f8
tree68e7fbf99f3e08db5bef2f679805d51f4d9f5bc4
parente0ca2e02120258aabca1e1586a58a8d672484fb5
tdb: fix recovery reuse after crash

If a process (or the machine) dies after just after writing the
recovery head (pointing at the end of file), the recovery record will filled
with 0x42.  This will not invoke a recovery on open, since rec.magic
!= TDB_RECOVERY_MAGIC.

Unfortunately, the first transaction commit will happily reuse that
area: tdb_recovery_allocate() doesn't check the magic.  The recovery
record has length 0x42424242, and it writes that back into the
now-valid-looking transaction header) for the next comer (which
happens to be tdb_wipe_all in my tests).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from commit b37b452cb8c1f56b37b04abe7bffdede371ca361)
lib/tdb/common/transaction.c