From nobody Fri Mar 24 16:58:30 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PjpLv0sVNz40pLL; Fri, 24 Mar 2023 16:58:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PjpLv0NpCz4Pl3; Fri, 24 Mar 2023 16:58:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679677111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2kMQeScycG6Jx77WdBRPeOdaAueJNJkeTsxQuN3H5kQ=; b=jd+8vvXqn/oKtDo9Oh9sMKsVxSNH1J1UHwxVEk1P6jLdHxF/uF8qAXKJPJhwmWbrhHAJU8 XMKgpMCKEhkbwuU+GG0qno5M7mv8SvRwhA5LDjRsa/ZnC+pNHWykQJ38+lX8b0gwm/JjG8 pEfZCisCo4ujM/oULjP4IMaXQ+nw+oHVjB4n/3Scbq2duXZJUBl2T19UbbVnrjxdGpLHY8 BI0w+VKtHVkgsvNDhily+cfTFw8BWTymE6uHIUQWbVIwNlG4fGnZ1Me/Zzlj8HIuBFzY7S 6H4Yoe8Koa9ojLA9vO0ZZ9WNxJD29t7jMvVy75EeHuaZSz1U6Rtx3hgR49M3Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679677111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2kMQeScycG6Jx77WdBRPeOdaAueJNJkeTsxQuN3H5kQ=; b=WowWA36WMbZUOha/zQ87dpuJiwq6zrlW515/Y3pdKksr980wE7zDM96gaSmN6GR0w8ZSIs c3+6uZMXBRQE57Bw+pT9joqTQWXzeZoXvSPjhzbFz4iwuwp8PAo2xL/LmAe634EsyhaetV WA8kUzJkCtUcL31vc+m1rJs+jzzNckqnKHt8CD+BYThh+HJOduwBDAqC59R4hxPvyQMs2A r1ojTxltgUUXB6kY9EVsWtlH6CfZJVajzs1/xlS07JBgG2z/MoVC/6LAILRDNgUK0onYfJ XZmGkytdboPTv01VPRp9lw6WMm8k0YAQx28p0TUM8KGiCibGntok+09HZ1X2pA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679677111; a=rsa-sha256; cv=none; b=wMC89ngx18Okg5K6IlHB3iFdcChmBPaWPHvXrjJ4RjysfkLlcNLxWx82GTwzxs4NHkTrb+ yTB8hQ3ozLRIXIbduEcoMtGObVionFH+Vl4T++aQIdJhzCyIqaCgmM1XpH3V0rAmeqz8E/ ZIU8N+8MIPrdkhw9qUrHUvkgjrlp71S5tNxnbf8kvfYKuJw7/4kAJaxL60XT8KsBuZwRFS vxc5211tYwXgkFS0FIrJGbK/FYUWiJg3SARyEULvUkqOgmtvBOQP90edYu8IQmbXAZ/Xly HVkoxasGSk/Vmsql79ax/N21/v3HWdxMDM7Nnlhu+rvpgMC7mXkNWRq3LVjdTQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PjpLt6Y88zQSc; Fri, 24 Mar 2023 16:58:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32OGwUQP093547; Fri, 24 Mar 2023 16:58:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32OGwUe7093546; Fri, 24 Mar 2023 16:58:30 GMT (envelope-from git) Date: Fri, 24 Mar 2023 16:58:30 GMT Message-Id: <202303241658.32OGwUe7093546@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3c7ef29e8998 - stable/13 - ping: Avoid magic numbers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3c7ef29e89982ff243b18fce2bac4355028da879 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3c7ef29e89982ff243b18fce2bac4355028da879 commit 3c7ef29e89982ff243b18fce2bac4355028da879 Author: Jose Luis Duran AuthorDate: 2023-03-17 13:24:44 +0000 Commit: Mark Johnston CommitDate: 2023-03-24 16:58:01 +0000 ping: Avoid magic numbers The sizeof(struct ip) is 20. The sizeof(struct in_addr) is 4. No functional change intended. Reviewed by: asomers, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39125 (cherry picked from commit 491263d7a640a85a6be40fd0c0a9397d072f0847) --- sbin/ping/ping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 2fc876e50776..796f29438a70 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1674,7 +1674,7 @@ pr_iph(struct ip *ip) int hlen; hlen = ip->ip_hl << 2; - cp = (u_char *)ip + 20; /* point to options */ + cp = (u_char *)ip + sizeof(struct ip); /* point to options */ (void)printf("Vr HL TOS Len ID Flg off TTL Pro cks Src Dst\n"); (void)printf(" %1x %1x %02x %04x %04x", @@ -1690,7 +1690,7 @@ pr_iph(struct ip *ip) memcpy(&ina, &ip->ip_dst.s_addr, sizeof ina); (void)printf(" %s ", inet_ntoa(ina)); /* dump any option bytes */ - while (hlen-- > 20) { + while (hlen-- > (int)sizeof(struct ip)) { (void)printf("%02x", *cp++); } (void)putchar('\n'); @@ -1710,7 +1710,7 @@ pr_addr(struct in_addr ina) if (options & F_NUMERIC) return inet_ntoa(ina); - hp = cap_gethostbyaddr(capdns, (char *)&ina, 4, AF_INET); + hp = cap_gethostbyaddr(capdns, (char *)&ina, sizeof(ina), AF_INET); if (hp == NULL) return inet_ntoa(ina);