svn commit: samba r6528 - in branches/SAMBA_4_0/source/lib: .
tdb/common
tridge at samba.org
tridge at samba.org
Sat Apr 30 09:04:14 GMT 2005
Author: tridge
Date: 2005-04-30 09:04:14 +0000 (Sat, 30 Apr 2005)
New Revision: 6528
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6528
Log:
- in tdb_fetch() we effectively disallowed zero length records by
returning NULL/0, which is the same as we used for a failure. Having
to look at tdb->ecode (which we never do) is too error prone.
Instead, tdb_fetch() should behave like malloc() and talloc(), where
zero length is not special and malloc(0) returns a valid pointer.
- similarly in data_blob(), asking for data_blob(NULL, 0) should
return a zero blob, but asking for data_blob(ptr, 0) should return a
zero length blob with a valid pointer, just like talloc() and malloc()
This change fixes the SummaryInformation stream stored in the tdb
backend when manipulated from w2k. The w2k client was using
SET_EOF_INFORMATION to create a zero-length stream, which we return
STATUS_NOT_FOUND on, as the tdb_fetch() gave us back a NULL/0 blob,
which we returned as not-found
Modified:
branches/SAMBA_4_0/source/lib/data_blob.c
branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/data_blob.c
===================================================================
--- branches/SAMBA_4_0/source/lib/data_blob.c 2005-04-30 08:38:32 UTC (rev 6527)
+++ branches/SAMBA_4_0/source/lib/data_blob.c 2005-04-30 09:04:14 UTC (rev 6528)
@@ -29,7 +29,7 @@
{
DATA_BLOB ret;
- if (length == 0) {
+ if (p == NULL && length == 0) {
ZERO_STRUCT(ret);
return ret;
}
Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdb.c 2005-04-30 08:38:32 UTC (rev 6527)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdb.c 2005-04-30 09:04:14 UTC (rev 6528)
@@ -1129,8 +1129,8 @@
/* find an entry in the database given a key */
/* If an entry doesn't exist tdb_err will be set to
* TDB_ERR_NOEXIST. If a key has no data attached
- * tdb_err will not be set. Both will return a
- * zero pptr and zero dsize.
+ * then the TDB_DATA will have zero length but
+ * a non-zero pointer
*/
TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key)
@@ -1145,11 +1145,8 @@
if (!(rec_ptr = tdb_find_lock_hash(tdb,key,hash,F_RDLCK,&rec)))
return tdb_null;
- if (rec.data_len)
- ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec) + rec.key_len,
- rec.data_len);
- else
- ret.dptr = NULL;
+ ret.dptr = tdb_alloc_read(tdb, rec_ptr + sizeof(rec) + rec.key_len,
+ rec.data_len);
ret.dsize = rec.data_len;
tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK);
return ret;
More information about the samba-cvs
mailing list