• Enable modification of headers - specifically updating or assigning "

    From Digital Man@1:103/705 to Deon George on Sun May 15 23:14:14 2022
    Re: Enable modification of headers - specifically updating or assigning "t
    By: Deon George to GitLab note in main/sbbs on Sat May 14 2022 06:43 am

    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.

    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?
    --
    digital man (rob)

    Rush quote #6:
    ... but most of us just dream about the things we'd like to be
    Norco, CA WX: 63.7øF, 61.0% humidity, 0 mph E wind, 0.00 inches rain/24hrs
    --- SBBSecho 3.15-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From deon@1:103/705 to Digital Man on Mon May 16 22:59:50 2022
    Re: Enable modification of headers - specifically updating or assigning "
    By: Digital Man to Deon George on Sun May 15 2022 11:14 pm

    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.

    Awesome thanks - and yes in my case, 4 chars is enough - but I can imagine if somebody else choose to use tags that it may be different.

    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).

    Yes, I think relocatable headers will be a better solution overall (then no config required)...

    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

    I did - issue 404.

    Tks...


    ...ëîåï

    ---
    þ Synchronet þ Alterant | an SBBS in Docker on Pi!
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)