From 184d3cf6c14eea7ee64dc9436b14d2f92d09dd93 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 22 Dec 2004 20:50:40 +0000
Subject: [PATCH] Added length field to hash_t (if lengths don't match,
 matching hashes are just a false positive and ignored). Added reserved
 (padding) for future hash types (e.g. SHA1) or other fields. Note: Existing
 *.hash files must be deleted and recreated with fixsmb to be useful (sorry).

---
 src/smblib/smbdefs.h | 2 ++
 src/smblib/smbhash.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/src/smblib/smbdefs.h b/src/smblib/smbdefs.h
index 047da91404..1992841ea1 100644
--- a/src/smblib/smbdefs.h
+++ b/src/smblib/smbdefs.h
@@ -494,11 +494,13 @@ typedef struct _PACK {
 
 	ulong	number;					/* Message number */
 	ulong	time;					/* Local time of fingerprinting */
+	ulong	length;					/* Length (in bytes) of source */
 	uchar	source;					/* SMB_HASH_SOURCE* (in low 5-bits) */
 	uchar	flags;					/* indications of valid hashes and pre-processing */
 	ushort	crc16;					/* CRC-16 of source */
 	ulong	crc32;					/* CRC-32 of source */
 	uchar	md5[MD5_DIGEST_SIZE];	/* MD5 digest of source */
+	uchar	reserved[28];			/* sizeof(hash_t) = 64 */
 
 } hash_t;
 
diff --git a/src/smblib/smbhash.c b/src/smblib/smbhash.c
index ba600ea4b9..d5c7ed117d 100644
--- a/src/smblib/smbhash.c
+++ b/src/smblib/smbhash.c
@@ -78,6 +78,8 @@ int SMBCALL smb_findhash(smb_t* smb, hash_t** compare, hash_t* found_hash,
 
 				if(compare[c]->source!=hash.source)
 					continue;	/* wrong source */
+				if(compare[c]->length!=hash.length)
+					continue;	/* wrong source length */
 				if(compare[c]->flags&SMB_HASH_MARKED)
 					continue;	/* already marked */
 				if((compare[c]->flags&SMB_HASH_PROC_MASK)!=(hash.flags&SMB_HASH_PROC_MASK))
@@ -180,6 +182,7 @@ hash_t* SMBCALL smb_hash(ulong msgnum, ulong t, unsigned source, unsigned flags
 
 	hash->number=msgnum;
 	hash->time=t;
+	hash->length=length;
 	hash->source=source;
 	hash->flags=flags;
 	if(flags&SMB_HASH_CRC16)
-- 
GitLab