Skip to content

htick filefix does not respond with reply kludge #18

@awehttam

Description

@awehttam

I noticed that FileFix does not respond with a REPLY kludge, but AreaFix does.

I asked Codex to take a look at it, and it implemented the following solution.

Summary
=======

This change fixes reply-linkage handling in `htick/src/scan.c`,
specifically in `convertMsgText()`.

Old behavior:
- Read the control buffer into `ctrlBuff`
- Convert `ctrlBuff` into printable kludge lines with `CvtCtrlToKludge()`
- Prepend those kludge lines to `msg->text`
- Free the original control buffer

New behavior:
- Read the control buffer into `ctrlBuff`
- Keep the raw control buffer by assigning it to `msg->ctl`
- Store the control buffer length in `msg->ctlLength`
- Build `msg->text` from the message body plus the generated Via line only
- Explicitly terminate `msg->text` and update `msg->textLength`

Why this matters:
- Reply metadata such as MSGID and REPLY stays available in the control data
- Later code can inspect the real control buffer instead of reparsing text
- The message body no longer gets synthetic kludge text prepended to it

Minimal patch
=============

Apply this patch from the repository root with:

  patch -p1 < filefix-reply-fix.diff

Patch contents:

--- a/htick/src/scan.c
+++ b/htick/src/scan.c
@@ -74,15 +74,16 @@
 void convertMsgText(HMSG SQmsg, s_message * msg, hs_addr ourAka)
 {
-    char * kludgeLines, viaLine[100];
+    char viaLine[100];
     UCHAR * ctrlBuff;
     UINT32 ctrlLen;
     time_t tm;
     struct tm * dt;

-    /*  get kludge lines */
+    /* preserve raw control data so RetMsg() can recover MSGID/REPLY linkage */
     ctrlLen  = MsgGetCtrlLen(SQmsg);
     ctrlBuff = (unsigned char *)smalloc(ctrlLen + 1);
     MsgReadMsg(SQmsg, NULL, 0, 0, NULL, ctrlLen, ctrlBuff);
-    kludgeLines = (char *)CvtCtrlToKludge(ctrlBuff);
-    nfree(ctrlBuff);
+    ctrlBuff[ctrlLen] = '\0';
+    msg->ctl          = (char *)ctrlBuff;
+    msg->ctlLength    = (hINT32)ctrlLen;
     /*  make text */
     msg->textLength = MsgGetTextLen(SQmsg);
@@ -105,21 +106,18 @@
-    msg->text = (char *)scalloc(1, msg->textLength + strlen(kludgeLines)
-                                + strlen(viaLine) + 1);
-    strcpy(msg->text, kludgeLines);
-/*    strcat(msg->text, "\001TID: "); */
-/*    strcat(msg->text, versionStr); */
-/*    strcat(msg->text, "\r"); */
+    msg->text = (char *)scalloc(1, msg->textLength + strlen(viaLine) + 1);
     MsgReadMsg(SQmsg,
                NULL,
                0,
                msg->textLength,
-               (unsigned char *)msg->text + strlen(msg->text),
+               (unsigned char *)msg->text,
                0,
                NULL);
+    msg->text[msg->textLength] = '\0';
     strcat(msg->text, viaLine);
+    msg->textLength += (hINT32)strlen(viaLine);

     if((!config->recodeMsgBase) && (config->outtab != NULL))
     {
         recodeToInternalCharset((char *)msg->text);
     }
-
-    nfree(kludgeLines);
 } /* convertMsgText */

Manual edit instructions
========================

If `patch` does not apply cleanly, make these edits in `convertMsgText()`:

1. Change:
     char * kludgeLines, viaLine[100];
   to:
     char viaLine[100];

2. Replace:
     kludgeLines = (char *)CvtCtrlToKludge(ctrlBuff);
     nfree(ctrlBuff);
   with:
     ctrlBuff[ctrlLen] = '\0';
     msg->ctl          = (char *)ctrlBuff;
     msg->ctlLength    = (hINT32)ctrlLen;

3. Change:
     msg->text = (char *)scalloc(1, msg->textLength +
                                 strlen(kludgeLines) +
                                 strlen(viaLine) + 1);
     strcpy(msg->text, kludgeLines);
   to:
     msg->text = (char *)scalloc(1, msg->textLength +
                                 strlen(viaLine) + 1);

4. Remove the commented-out `strcat()` lines for `TID` and `versionStr`.

5. Change:
     (unsigned char *)msg->text + strlen(msg->text)
   to:
     (unsigned char *)msg->text

6. Add after `MsgReadMsg(...)`:
     msg->text[msg->textLength] = '\0';

7. Add after `strcat(msg->text, viaLine);`:
     msg->textLength += (hINT32)strlen(viaLine);

8. Remove:
     nfree(kludgeLines);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions