53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
|
From 8687974a09430df54a9424775ddd131cc270794b Mon Sep 17 00:00:00 2001
|
||
|
From: Deon George <deon@leenooks.net>
|
||
|
Date: Sat, 28 May 2022 11:42:25 +1000
|
||
|
Subject: [PATCH] Feature main/sbbs#404 - Reserve space (up to tagsBuffer) so
|
||
|
that headers can be modified, and tags can be added up to tagsBuffer in size
|
||
|
|
||
|
---
|
||
|
src/smblib/smblib.c | 21 +++++++++++++++++++++
|
||
|
1 file changed, 21 insertions(+)
|
||
|
|
||
|
diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c
|
||
|
index 53b886392..29624a79a 100644
|
||
|
--- a/src/smblib/smblib.c
|
||
|
+++ b/src/smblib/smblib.c
|
||
|
@@ -1603,6 +1603,7 @@ int smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
|
||
|
ulong hdrlen;
|
||
|
off_t idxlen;
|
||
|
size_t idxreclen = smb_idxreclen(smb);
|
||
|
+ int tagsBuffer = 4; /* @todo this should be determined from a system configuration item */
|
||
|
|
||
|
if(smb->shd_fp==NULL) {
|
||
|
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s msgbase not open", __FUNCTION__);
|
||
|
@@ -1612,6 +1613,26 @@ int smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
|
||
|
if(!smb->locked && smb_locksmbhdr(smb)!=SMB_SUCCESS)
|
||
|
return(SMB_ERR_LOCK);
|
||
|
|
||
|
+ /* Add a tags buffer if a tag doesnt exist. */
|
||
|
+ if (tagsBuffer) {
|
||
|
+ int hasTags = 0;
|
||
|
+
|
||
|
+ for(i=0;i<msg->total_hfields;i++) {
|
||
|
+ if (msg->hfield[i].type == SMB_TAGS) {
|
||
|
+ hasTags = 1;
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ }
|
||
|
+ if (! hasTags) {
|
||
|
+ if (i=smb_hfield_add(msg,SMB_TAGS,tagsBuffer,"",TRUE) != SMB_SUCCESS) {
|
||
|
+ safe_snprintf(smb->last_error,sizeof(smb->last_error)
|
||
|
+ ,"%s error adding padding for TAG field", __FUNCTION__);
|
||
|
+ smb_unlocksmbhdr(smb);
|
||
|
+ return(i);
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
hdrlen=smb_getmsghdrlen(msg);
|
||
|
if(hdrlen>SMB_MAX_HDR_LEN) { /* headers are limited to 64k in size */
|
||
|
smb_unlocksmbhdr(smb);
|
||
|
--
|
||
|
2.31.1
|
||
|
|