Add patch to reserve space for tags in message headers

This commit is contained in:
Deon George 2022-05-28 13:07:54 +10:00
parent 363a9184c0
commit c6930db160
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,52 @@
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

View File

@ -36,10 +36,13 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Build SBBS # Build SBBS
COPY 0001-Feature-main-sbbs-404-Reserve-space-up-to-tagsBuffer.patch /tmp/
RUN apt-get update \ RUN apt-get update \
&& apt-get install -yqq git build-essential libnspr4-dev libncurses5-dev libncursesw5-dev libarchive-dev cvs wget pkgconf libcap2-bin sudo libarchive13 \ && apt-get install -yqq git build-essential libnspr4-dev libncurses5-dev libncursesw5-dev libarchive-dev cvs wget pkgconf libcap2-bin sudo libarchive13 \
&& mkdir /opt/sbbs && cd /tmp \ && mkdir /opt/sbbs && cd /tmp \
&& wget https://gitlab.synchro.net/sbbs/sbbs/-/raw/master/install/GNUmakefile \ && wget https://gitlab.synchro.net/sbbs/sbbs/-/raw/master/install/GNUmakefile \
&& git clone https://gitlab.com/SynchronetBBS/sbbs.git /opt/sbbs/repo \
&& cd /opt/sbbs/repo && git apply /tmp/0001-Feature-main-sbbs-404-Reserve-space-up-to-tagsBuffer.patch && cd /tmp && rm /tmp/*patch \
&& make RELEASE=1 USE_DOSEMU=1 NO_X=1 SBBSDIR=/opt/sbbs install \ && make RELEASE=1 USE_DOSEMU=1 NO_X=1 SBBSDIR=/opt/sbbs install \
&& rm -rf /opt/sbbs/3rdp /opt/sbbs/src \ && rm -rf /opt/sbbs/3rdp /opt/sbbs/src \
&& mv /opt/sbbs/ctrl /opt/sbbs/ctrl.orig \ && mv /opt/sbbs/ctrl /opt/sbbs/ctrl.orig \