jcs
/subtext
/amendments
/572
fidopkt: Fix return value when aborting parse early
jcs made amendment 572 about 1 year ago
--- fidopkt.c Tue Nov 21 21:52:42 2023
+++ fidopkt.c Sat Dec 2 19:49:38 2023
@@ -200,7 +200,7 @@ fidopkt_parse_message(char *packet_filename, struct fi
size_t body_len, len, llen, msg_size, msg_size_limited;
long tzoff = 0;
char dmon[6];
- short dday, dyear, dhour, dmin, dsec, dutc, attr, n;
+ short dday, dyear, dhour, dmin, dsec, dutc, attr, n, val;
bool tear;
#ifdef FIDOPKT_DEBUG
@@ -213,23 +213,23 @@ fidopkt_parse_message(char *packet_filename, struct fi
if (header == NULL) {
if (len < FIDOPKT_HEADER_SIZE) {
logger_printf("[fidopkt] Packet too small (%ld)", len);
- return;
+ return NULL;
}
- if (GET_U16(buf + FIDOPKT_PKTTYPE) != 2) {
- logger_printf("[fidopkt] Not a FidoNet packet");
- return;
+ if ((val = GET_U16(buf + FIDOPKT_PKTTYPE)) != 2) {
+ logger_printf("[fidopkt] Not a FidoNet packet (0x%x)", val);
+ return NULL;
}
if (GET_U16(buf + FIDOPKT_BAUD) == 2) {
logger_printf("[fidopkt] 5d format not supported");
- return;
+ return NULL;
}
if (buf[FIDOPKT_CWVALIDCOPY] != buf[FIDOPKT_CAPABILWORD + 1] ||
buf[FIDOPKT_CWVALIDCOPY + 1] != buf[FIDOPKT_CAPABILWORD]) {
logger_printf("[fidopkt] Not in 4d format");
- return;
+ return NULL;
}
if (GET_U16(buf + FIDOPKT_ORIGZONE) != 0) {
@@ -256,12 +256,12 @@ fidopkt_parse_message(char *packet_filename, struct fi
if (len < FIDOPKT_MSG_HEADER_SIZE) {
logger_printf("[fidopkt] Message header too short");
- return;
+ return NULL;
}
- if (GET_U16(buf + FIDOPKT_MSG_PKTTYPE) != 2) {
- logger_printf("[fidopkt] Header packet type != 2");
- return;
+ if ((val = GET_U16(buf + FIDOPKT_MSG_PKTTYPE)) != 2) {
+ logger_printf("[fidopkt] Header packet type != 2 (0x%x)", val);
+ return NULL;
}
attr = GET_U16(buf + FIDOPKT_MSG_ATTR);