AmendHub

Download:

jcs

/

subtext

/

amendments

/

328

fidopkt: Enlarge msgid_orig, use non-fatal malloc/calloc


jcs made amendment 328 about 1 year ago
--- fidopkt.c Sat Feb 25 15:28:56 2023 +++ fidopkt.c Tue Feb 28 21:04:15 2023 @@ -223,7 +223,11 @@ fidopkt_parse(char *packet_filename, char *buf, size_t buf += SIZE_PKTMSGHEADER; len -= SIZE_PKTMSGHEADER; - ret = xmalloczero(sizeof(struct fidopkt), "fidopkt"); + ret = calloc(sizeof(struct fidopkt), 1); + if (ret == NULL) { + logger_printf("[fidopkt] malloc failed"); + goto parse_fail; + } fidopkt_read_until(&buf, &len, '\0', sizeof(line), line, true); if (len == 0) { @@ -284,7 +288,11 @@ fidopkt_parse(char *packet_filename, char *buf, size_t } strlcpy(ret->area, line + 5, sizeof(ret->area)); - ret->message = xmalloc(len, "fidopkt message"); + ret->message = malloc(len); + if (ret->message == NULL) { + logger_printf("[fidopkt] malloc(%lu) failed", len); + goto parse_fail; + } message_len = 0; tear = false; @@ -400,6 +408,7 @@ fidopkt_free(struct fidopkt **pktp) struct fidopkt *pkt = (struct fidopkt *)*pktp; if (pkt->message) - xfree(&pkt->message); - xfree(pktp); + free(pkt->message); + free(pkt); + *pktp = NULL; } --- fidopkt.h Fri Feb 24 16:08:12 2023 +++ fidopkt.h Tue Feb 28 15:25:34 2023 @@ -27,7 +27,7 @@ struct fidopkt { char area[16]; char origin[72]; char reply[32]; - char msgid_orig[32]; + char msgid_orig[64]; unsigned long msgid; unsigned short msgid_zone; unsigned short msgid_net;