https://gitlab.synchro.net/main/sbbs/-/issues/404#note_2579
Hey @rswindell I thought I'd have a go and implementing this. Implementing header relocation (if it is possible) is way beyond my skill set, so I had a go at the second option - reserving some space during message add.
Here is what I came up with:
```
diff --git a/src/smblib/smblib.c b/src/smblib/smblib.c
index 53b886392..37511ff95 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; /* this should be determine 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,24 @@ 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;
+ }
+ if (! hasTags) {
+ if (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);
```
Have I implemented this correctly - ie: I'm hoping it wont cause any other issues? My (limited) testing seemed to work well and I didnt get any `ERROR:smb_putmsghdr illegal header length increase: ...` errors.
What I didnt know what to do, was to implement the "configurable part" to this patch - ie: would you define it in scfg or in sbbsecho.ini (or somewhere else)? And while I could probably fumble my way around adding that configuration option, I dont know the best way to make that configuration option visible in that function (and thus ultimately the value of `tagsBuffer`).
If it is simple enough, if you could provide some pointers, I'll happily have a go - otherwise if this patch doesnt have any side affects, I may run with it until this feature is implemented properly.
Have I implemented this correctly - ie: I'm hoping it wont cause any other issues? My (limited) testing seemed to work well and I
didnt get any `ERROR:smb_putmsghdr illegal header length increase: ...` errors.
I guess its okay as long as the tags you add aren't more than 4 characters.
What I didnt know what to do, was to implement the "configurable part" to this patch - ie: would you define it in scfg or in
sbbsecho.ini (or somewhere else)? And while I could probably fumble my way around adding that configuration option, I dont know the
best way to make that configuration option visible in that function (and thus ultimately the value of `tagsBuffer`).
I would rather have a generic "unused" head space allocation or support the relocatable headers (preferred).
If it is simple enough, if you could provide some pointers, I'll happily have a go - otherwise if this patch doesnt have any side
affects, I may run with it until this feature is implemented properly.
Yeah, I'll give some thought to relocatable headers. I think you already created a gitlab issue/request, right?
https://gitlab.synchro.net/main/sbbs/-/issues/404#note_2579
Sysop: | altere |
---|---|
Location: | Houston, TX |
Users: | 60 |
Nodes: | 4 (0 / 4) |
Uptime: | 13:38:23 |
Calls: | 516 |
Files: | 7,037 |
Messages: | 288,554 |