summaryrefslogtreecommitdiff
path: root/lib/tdb/common/check.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-12-19 15:47:50 +1030
committerRusty Russell <rusty@rustcorp.com.au>2011-12-19 07:52:01 +0100
commitb64494535dc62f4073fc6302847593ed6e6ec38b (patch)
treefc81a835f7f0c559b1d85fb3ebc33b0f9e4e42b0 /lib/tdb/common/check.c
parent6260d8c29b4828511ecd1c3fc176612e0a0c73ce (diff)
downloadsamba-b64494535dc62f4073fc6302847593ed6e6ec38b.tar.gz
samba-b64494535dc62f4073fc6302847593ed6e6ec38b.tar.bz2
samba-b64494535dc62f4073fc6302847593ed6e6ec38b.zip
tdb: be more careful on 4G files.
I came across a tdb which had wrapped to 4G + 4K, and the contents had been destroyed by processes which thought it only 4k long. Fix this by checking on open, and making tdb_oob() check for wrap itself. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Autobuild-User: Rusty Russell <rusty@rustcorp.com.au> Autobuild-Date: Mon Dec 19 07:52:01 CET 2011 on sn-devel-104
Diffstat (limited to 'lib/tdb/common/check.c')
-rw-r--r--lib/tdb/common/check.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 3387fbd098..313f55cbb0 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -92,7 +92,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
off, rec->next));
goto corrupt;
}
- if (tdb->methods->tdb_oob(tdb, rec->next+sizeof(*rec), 0))
+ if (tdb->methods->tdb_oob(tdb, rec->next, sizeof(*rec), 0))
goto corrupt;
/* Check rec_len: similar to rec->next, implies next record. */
@@ -110,7 +110,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
goto corrupt;
}
/* OOB allows "right at the end" access, so this works for last rec. */
- if (tdb->methods->tdb_oob(tdb, off+sizeof(*rec)+rec->rec_len, 0))
+ if (tdb->methods->tdb_oob(tdb, off, sizeof(*rec)+rec->rec_len, 0))
goto corrupt;
/* Check tailer. */
@@ -345,7 +345,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
}
/* Make sure we know true size of the underlying file. */
- tdb->methods->tdb_oob(tdb, tdb->map_size + 1, 1);
+ tdb->methods->tdb_oob(tdb, tdb->map_size, 1, 1);
/* Header must be OK: also gets us the recovery ptr, if any. */
if (!tdb_check_header(tdb, &recovery_start))