From nobody Fri Mar 17 13:29:19 2023 X-Original-To: dev-commits-src-main@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 4PdQ2l2dnxz3yNC6; Fri, 17 Mar 2023 13:29:19 +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 4PdQ2l27BTz3tY8; Fri, 17 Mar 2023 13:29:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679059759; 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=+sg7RuX/QtRe1AYhOurE/sATpJclm8HKeDKkhT9+f8A=; b=UG99G48Ns5YpwasfYAUIzIuJsxc3m56dzl/SDc5kp/Z4VQPA08Ikhay78E6e8lZGRCJjel /1HugNWkoanlz7+vHGNowiYc3FTGNY2Wsi4U0uJLeaJhK9dPgJyFWjahLE/B1kGCvFMxqw PJIyilBece+W+qnZwNZ09HoXa5WzAeg5zndArpvMfvVfbg5I8eIL91aF57x8pBqfF+pOWE 3Pqzda/GFR7PUPLzNUrR8LZjCQ4H+Jh/ZMERhsrcMF/T/4UzY4Zhvv8IGGShyq7teu4Ytz Oxflz53/CkB/Yu/nJ5ZoKxuams4mihdNEbHeTRd+MlQ/7iMGWiEEDUEOv287NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679059759; 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=+sg7RuX/QtRe1AYhOurE/sATpJclm8HKeDKkhT9+f8A=; b=TUEQJGvE6pb1cfnTkpwm9+LpkDuLxrRCtfh12vo3PF2ilZMNXIuz2TaMmj+gp7Wy2c7aXU dkzOw2I4YfV1bAdN/OIPku8xXZ7V7rArOOgSu56EKm9SN50MGwpg+JebucIzIS61e9Dfhz mnQ14t4vFP6z1T2NjF1x5Q6pnp59lzT7sg7TchrDJH0TIGPxy0ncxNZdlm70vam3deqZAJ GYC5fSRI8NTz3KbYdLe2Gmfozv+zNo7+mZPR2CCkjCcqX6z1cKTuc/16Z8+ZHKLTavCnpH f59Pad0002DxPjJ82m+mkdM7cRO/k3mTes8e15bHGdQkNYKv2wOYW+9rIp/w8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679059759; a=rsa-sha256; cv=none; b=fyjn8lZu9txL5iacO4nAucmwWTZE4CTvQVwN0BzeELWMRkqVi/lQcuTb9AXmSESbrV0WDO jMZjGUlfM5tnIHObMpZ2s6gHTh96hlv+03E29fnRdXDHMxGXr4dTU6xPJvtnnxrTJQSkfs zDu5jThnszryMA1uzwXaXmfyQa/gmfWgMsc81lVXs7hSr5vV/DHgNTFQzHty1gycFMDM0w uaFv9HFY3AKG+i4G3aOZm7KcM2IG5gIurjtFbSZBylFTbKxKk8sFneTKTXSvf6i+uo8e+e HoR0VJDgCM7hThUXdcno2W3CeZvnWRjm2XqMfu7g8E9oEZ0+zL7yCNnCuMgnkg== 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 4PdQ2l1B5PzRZS; Fri, 17 Mar 2023 13:29:19 +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 32HDTJtr063689; Fri, 17 Mar 2023 13:29:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32HDTJj7063688; Fri, 17 Mar 2023 13:29:19 GMT (envelope-from git) Date: Fri, 17 Mar 2023 13:29:19 GMT Message-Id: <202303171329.32HDTJj7063688@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 491263d7a640 - main - ping: Avoid magic numbers List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 491263d7a640a85a6be40fd0c0a9397d072f0847 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=491263d7a640a85a6be40fd0c0a9397d072f0847 commit 491263d7a640a85a6be40fd0c0a9397d072f0847 Author: Jose Luis Duran AuthorDate: 2023-03-17 13:24:44 +0000 Commit: Mark Johnston CommitDate: 2023-03-17 13:24:44 +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 --- 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 6e069adfecfa..fe319bfb70a5 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1670,7 +1670,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", @@ -1686,7 +1686,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'); @@ -1706,7 +1706,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);