summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/nsswitch/winbindd_cache.c38
2 files changed, 20 insertions, 20 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 35355becdf..2d80efaa1a 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -188,7 +188,7 @@ MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(IDMAP_MODULES) $(CHARSE
######################################################################
TDBBASE_OBJ = tdb/common/tdb.o tdb/common/dump.o tdb/common/error.o \
- tdb/common/freelist.o tdb/common/io.o tdb/common/lock.o \
+ tdb/common/freelist.o tdb/common/freelistcheck.o tdb/common/io.o tdb/common/lock.o \
tdb/common/open.o tdb/common/transaction.o tdb/common/traverse.o
TDB_OBJ = $(TDBBASE_OBJ) lib/util_tdb.o tdb/common/tdbback.o
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index 436f5d1874..b742ca37dd 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -372,7 +372,7 @@ static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now )
static NTSTATUS store_cache_seqnum( struct winbindd_domain *domain )
{
- TDB_DATA data, key;
+ TDB_DATA data;
fstring key_str;
char buf[8];
@@ -382,15 +382,13 @@ static NTSTATUS store_cache_seqnum( struct winbindd_domain *domain )
}
fstr_sprintf( key_str, "SEQNUM/%s", domain->name );
- key.dptr = key_str;
- key.dsize = strlen(key_str)+1;
SIVAL(buf, 0, domain->sequence_number);
SIVAL(buf, 4, domain->last_seq_check);
data.dptr = buf;
data.dsize = 8;
- if ( tdb_store( wcache->tdb, key, data, TDB_REPLACE) == -1 ) {
+ if ( tdb_store_bystring( wcache->tdb, key_str, data, TDB_REPLACE) == -1 ) {
DEBUG(10,("store_cache_seqnum: tdb_store fail key [%s]\n", key_str ));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -2703,23 +2701,14 @@ static int cache_traverse_validate_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_D
{
int i;
- /* Ensure key is valid. */
- if (kbuf.dsize < 3) {
- return 1; /* terminate. */
- }
- /* Ensure key is a string. */
- if (kbuf.dptr[kbuf.dsize] != '\0') {
- return 1; /* terminate. */
- }
-
for (i = 0; key_val[i].keyname; i++) {
- if (strncmp(key_val[i].keyname, kbuf.dptr, strlen(key_val[i].keyname)) == 0) {
- if (key_val[i].validate_data_fn(kbuf, dbuf)) {
- return 1; /* terminate. */
- }
+ size_t namelen = strlen(key_val[i].keyname);
+ if (kbuf.dsize >= namelen && (
+ strncmp(key_val[i].keyname, kbuf.dptr, namelen)) == 0) {
+ return key_val[i].validate_data_fn(kbuf, dbuf);
}
}
- return 0;
+ return 1; /* terminate. */
}
/* Handle any signals generated when validating a possibly
@@ -2758,6 +2747,7 @@ int winbindd_validate_cache(void)
{
BOOL ret = -1;
int fd = -1;
+ int num_entries = 0;
TDB_CONTEXT *tdb = NULL;
const char *cache_path = lock_path("winbindd_cache.tdb");
@@ -2792,12 +2782,22 @@ int winbindd_validate_cache(void)
fd = tdb_fd(tdb);
+ /* Check the cache freelist is good. */
+ if (tdb_validate_freelist(tdb, &num_entries) == -1) {
+ DEBUG(0,("winbindd_validate_cache: bad freelist in cache %s\n",
+ cache_path));
+ goto out;
+ }
+
/* Now traverse the cache to validate it. */
if (tdb_traverse(tdb, cache_traverse_validate_fn, NULL)) {
+ DEBUG(0,("winbindd_validate_cache: cache %s traverse failed\n",
+ cache_path));
goto out;
}
- DEBUG(10,("winbindd_validate_cache: cache %s is good\n", cache_path));
+ DEBUG(10,("winbindd_validate_cache: cache %s is good "
+ "freelist has %d entries\n", cache_path, num_entries));
ret = 0; /* Cache is good. */
out: