AmendHub

Download:

jcs

/

subtext

/

amendments

/

543

fidopkt: Do proper message/packet termination


jcs made amendment 543 about 1 year ago
--- fidopkt.c Tue Nov 14 17:15:08 2023 +++ fidopkt.c Wed Nov 15 08:48:09 2023 @@ -706,9 +706,13 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch off += sprintf(buf + off, " * Origin: %s\r", msg->origin); } - /* packets are terminated by two nulls */ - if (!grow_to_fit(&buf, &buf_size, off, 2, 2)) + /* + * Messages are terminated by a null, and the whole packet is + * terminated by two nulls. + */ + if (!grow_to_fit(&buf, &buf_size, off, 3, 3)) goto fail; + buf[off++] = '\0'; buf[off++] = '\0'; buf[off++] = '\0';