git: 4630a3252ac8 - main - ping: Fix an uninitialized variable

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Fri, 24 Mar 2023 05:00:14 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=4630a3252ac8ad2f5acddf0d1efb26795cb3190b

commit 4630a3252ac8ad2f5acddf0d1efb26795cb3190b
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2023-03-24 04:53:54 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-03-24 04:58:28 +0000

    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) &&