From e522de480891b9d72ba4cd2d4c8decb6909809a9 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 10 May 2000 00:05:27 +0000 Subject: Using a structure for a tdb key can lead to insideous, hard to find bugs. On 64 bit IRIX, structure packing means that a struct { SMB_DEV_T dev /* 4 bytes */ SMB_INO_T ino /* 8 bytes */ } has 4 bytes of padding between the two members. If you don't null the memory before using it as a tdb key, you randomly can't find keys depending on what is in the padding. This caused me immense pain and was hard to track down.... :-) Jeremy. (This used to be commit f2a5ba3f0939f59097f0ef6a25f1cf9b5574f157) --- source3/locking/posix.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/locking/posix.c') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 0ab46f9ca4..d1edb1ef57 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -73,6 +73,8 @@ static TDB_DATA locking_key(SMB_DEV_T dev, SMB_INO_T inode) { static struct posix_lock_key key; TDB_DATA kbuf; + + memset(&key, '\0', sizeof(key)); key.device = dev; key.inode = inode; kbuf.dptr = (char *)&key; -- cgit