jcs
/subtext
/amendments
/539
fidopkt: Stop encoding body when we see a null byte
Also, don't include an additional blank line at the end unless we
are about to include a tear line with origin.
jcs made amendment 539 about 1 year ago
--- fidopkt.c Tue Apr 18 23:59:35 2023
+++ fidopkt.c Tue Nov 14 17:15:08 2023
@@ -671,6 +671,7 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch
if (!grow_to_fit(&buf, &buf_size, off, msg->body_len + 7,
msg->body_len + 7))
goto fail;
+
/*
* FidoNet messages can only have \r line-breaks and we probably used
* \r\n during the message editor, so strip out \n.
@@ -679,6 +680,9 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch
if (n == msg->body_len - 1 && msg->body[n] == '\r')
/* supress trailing \r, we'll add two next */
continue;
+
+ if (msg->body[n] == '\0')
+ break;
if (msg->body[n] == '\n') {
if (msg->body[n - 1] == '\r')
@@ -688,12 +692,13 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch
buf[off++] = msg->body[n];
}
- off += sprintf(buf + off, "\r\r");
+ off += sprintf(buf + off, "\r");
if (msg->origin[0]) {
/* add tear line */
- off += sprintf(buf + off, "--- \r");
+ off += sprintf(buf + off, "\r--- \r");
+ /* " * Origin: " */
len = 11 + strlen(msg->origin) + 2;
if (!grow_to_fit(&buf, &buf_size, off, len, len))