From 4630a3252ac8ad2f5acddf0d1efb26795cb3190b Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Thu, 23 Mar 2023 21:53:54 -0700 Subject: [PATCH] ping: Fix an uninitialized variable The variable oicmp, which holds the original ("quoted packet") ICMP packet in a structured way, did not have a copy of the original ICMP packet obtained from the raw data. The code was accidentally removed in 20b41303140e. Bring it back. Reported by: Coverity Scan, cy Reviewed by: cy CID: 1506960 (UNINIT) Fixes: 20b41303140eee4dfb896558fb83600c5f013d39 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39233 --- sbin/ping/ping.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 6b82fe3da9de..965b565da7b9 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1156,6 +1156,7 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) struct ip oip; u_char oip_header_len; struct icmp oicmp; + const u_char *oicmp_raw; /* * Get size of IP header of the received packet. @@ -1359,6 +1360,8 @@ pr_pack(char *buf, ssize_t cc, struct sockaddr_in *from, struct timespec *tv) } memcpy(&oip, icmp_data_raw, sizeof(struct ip)); + oicmp_raw = icmp_data_raw + oip_header_len; + memcpy(&oicmp, oicmp_raw, sizeof(struct icmp)); if (((options & F_VERBOSE) && uid == 0) || (!(options & F_QUIET2) &&