From c7ee63bb9e5929ee1325d36a34b12f5680016884 Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Wed, 9 Mar 2022 22:33:47 -0500 Subject: [PATCH] KA10: Clean up coverity errors. --- PDP10/kl10_nia.c | 2 ++ PDP10/kx10_imp.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/PDP10/kl10_nia.c b/PDP10/kl10_nia.c index 82d9765..f4d9a61 100644 --- a/PDP10/kl10_nia.c +++ b/PDP10/kl10_nia.c @@ -1080,6 +1080,8 @@ void nia_packet_debug(struct nia_device *nia, const char *action, case ICMP_PROTO: icmp = (struct icmp *)payload; len = ntohs(ip->ip_len) - (ip->ip_v_hl & 0xf) * 4; + if (len > 1500) + len = 1500; sim_debug(DEBUG_ICMP, &nia_dev, "%s %s %d byte packet from %s to %s\n", action, (icmp->type < sizeof(icmp_types)/sizeof(icmp_types[0])) ? icmp_types[icmp->type] : "", (int)len, src_ip, dst_ip); if (len && (nia_dev.dctrl & DEBUG_ICMP)) diff --git a/PDP10/kx10_imp.c b/PDP10/kx10_imp.c index 31bfb29..a421f84 100644 --- a/PDP10/kx10_imp.c +++ b/PDP10/kx10_imp.c @@ -1508,6 +1508,8 @@ imp_packet_in(struct imp_device *imp) int i; char port_buffer[100]; struct udp_hdr udp_hdr; + if (l > 1500) + l = 1500; /* Count out 4 commas */ for (i = nlen = 0; i < l && nlen < 4; i++) { if (tcp_payload[i] == ',') @@ -2098,6 +2100,8 @@ void imp_packet_debug(struct imp_device *imp, const char *action, ETH_PACK *pack } len = ntohs(ip->ip_len) - ((ip->ip_v_hl & 0xf) * 4 + (ntohs(tcp->flags) >> 12) * 4); + if (len > 1500) + len = 1500; sim_debug(DEBUG_TCP, &imp_dev, "%s %s%s %d byte packet from %s:%s to %s:%s\n", action, flags, *flags ? ":" : "", (int)len, src_ip, src_port, dst_ip, dst_port); if (len && (imp_dev.dctrl & DEBUG_TCP))