From 25c093f8a3f128f7196c8171273e65b44541b84e Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 9 Sep 2004 00:07:06 +0000
Subject: [PATCH] Bugfix: the msg.hdr.number must be set before calling
 smb_hashmsg() or an invalid (0) message number will be used for the hash
 entry.

---
 src/smblib/smblib.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c
index a35bc3ebe5..a2a18f6207 100644
--- a/src/smblib/smblib.c
+++ b/src/smblib/smblib.c
@@ -1452,15 +1452,16 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
 		return(SMB_ERR_HDR_LEN);
 	}
 
-	if(!(msg->flags&MSG_FLAG_HASHED) /* not already hashed */
-		&& (i=smb_hashmsg(smb,msg,NULL,FALSE))!=SMB_SUCCESS) {
+	if((i=smb_getstatus(smb))!=SMB_SUCCESS) {
 		smb_unlocksmbhdr(smb);
-		return(i);	/* Duplicate message? */
+		return(i);
 	}
+	msg->idx.number=msg->hdr.number=smb->status.last_msg+1;
 
-	if((i=smb_getstatus(smb))!=SMB_SUCCESS) {
+	if(!(msg->flags&MSG_FLAG_HASHED) /* not already hashed */
+		&& (i=smb_hashmsg(smb,msg,NULL,FALSE))!=SMB_SUCCESS) {
 		smb_unlocksmbhdr(smb);
-		return(i);
+		return(i);	/* Duplicate message? */
 	}
 
 	if(storage!=SMB_HYPERALLOC && (i=smb_open_ha(smb))!=SMB_SUCCESS) {
@@ -1482,7 +1483,6 @@ int SMBCALL smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
 		return(l); 
 	}
 
-	msg->idx.number=msg->hdr.number=smb->status.last_msg+1;
 	msg->idx.offset=smb->status.header_offset+l;
 	msg->idx.time=msg->hdr.when_imported.time;
 	msg->idx.attr=msg->hdr.attr;
-- 
GitLab