From nobody Sun Dec 22 07:49:36 2024 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 4YGCwc2Wtxz5jDJQ; Sun, 22 Dec 2024 07:49:36 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YGCwc1gy7z4h1N; Sun, 22 Dec 2024 07:49:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853776; 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=7bFdKwQmcYtIjgNiW0quOYnw95riYgjgw3bzofrhEVg=; b=n+lMsvKfZyTQD6tH8jg7eDvF3Bk5oCCyMzwLQjYkc2DCqvj8RSxj2vsvuNoZDMlLVcfr2e kECagdiiOBhLqq3tBSFof1LqC0NOq8272Td54qu5RFWI0zkUDzESTdYejjZLUTClW7NUzk 0ghRimoGf71Dr5JXeonEy1pQFZ6GkO3b83SW3T7V9bO5PTcyGrZjg6b3R4Lrz5SanXTXc5 Ss9tp/QbzKwfHs79vjhNoJqtz7bMcxlJQUF1c82k6FTeLGfJVZoKXjnFikEjAbQBPvoS3x QZOeXUP5TmCdXLjbAHTTNyF9LQ8sq2BFNlFVLQyLIDEzFTJ6WBB4U18tMmfdhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853776; 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=7bFdKwQmcYtIjgNiW0quOYnw95riYgjgw3bzofrhEVg=; b=dCB2Qv25hVPdL7hvGe4R8v32DD5r1YNqqkPZfYGM85GnjHCT753of3xOUnrosfHzfP0ryR 7FodiNB48p0wzcRC8/gL06PuG6yiPx+FNZwh9XpgLc8v9utZ1SNOlAYxuLcM33T38PTupL rlFdMQTlhfQ5REQeJfM/DKzjOt0M06DGKsvAt0aOe63moIRhAb/sEyPgMysWQwgsF6WEtU 2jAYD1wxodM1EyWkrL8Vh8W5bBfbLoogzIJ9a1JRA1nhdsjXMcDsRTAGxMpS6mBIlzuEYj ZU873Y737kaqKZQvXhgGooa9WbVVNu02bguuVkceSulBZA9THKWGwYiSVVCRhQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734853776; a=rsa-sha256; cv=none; b=GoRGAWevczokYcYkC/GwcpC2g1kOH8yopIJoq16z+vjnGFJcOoQRBKc9DY97KR0H/7XQ0E 606+It+2cVhnWXqu8Zki3828JmiqEaxAg4DfwX/7idWFQ5y/Wh3gcbTi+L3DKI+30M9FLz R3KWp8dp4IUR/sDRQtYNKonFsivwK9vTzV7G6F8UxEp9W7+3scIvq2yZ6m7TOLE5uqRlyA q6C3hUKiZZYknarzdys9XshUu8dJ3L6ivSdfp+p45Weg+W8ugcW+2YRbcTe6jG8zo8pffh YOoTi5q0ShRRuYruPA9gIDLBwZCK3x50JxNFlW9DgKU8NeVTvv845sX8W6SPcA== 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 4YGCwc1Dk0z103V; Sun, 22 Dec 2024 07:49:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BM7naTF023427; Sun, 22 Dec 2024 07:49:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BM7nanW023424; Sun, 22 Dec 2024 07:49:36 GMT (envelope-from git) Date: Sun, 22 Dec 2024 07:49:36 GMT Message-Id: <202412220749.4BM7nanW023424@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 538bf98c7c3a - stable/14 - MFC: hexdump: Do not trust st_size if it equals zero. 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 538bf98c7c3ad65b6fa70cadd86635139c689097 Auto-Submitted: auto-generated The branch stable/14 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=538bf98c7c3ad65b6fa70cadd86635139c689097 commit 538bf98c7c3ad65b6fa70cadd86635139c689097 Author: Ricardo Branco AuthorDate: 2024-01-03 20:17:58 +0000 Commit: Xin LI CommitDate: 2024-12-22 07:49:29 +0000 MFC: hexdump: Do not trust st_size if it equals zero. PR: bin/276106 (cherry picked from commit e23954bd42fe4331b67ba8f6446bcccf751096f1) --- usr.bin/hexdump/display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 6c0018dcef3c..a32585c296ef 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -397,13 +397,14 @@ doskip(const char *fname, int statok) if (statok) { if (fstat(fileno(stdin), &sb)) err(1, "%s", fname); - if (S_ISREG(sb.st_mode) && skip > sb.st_size) { + if (S_ISREG(sb.st_mode) && skip > sb.st_size && sb.st_size > 0) { address += sb.st_size; skip -= sb.st_size; return; } } - if (!statok || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) { + if (!statok || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode) || \ + (S_ISREG(sb.st_mode) && sb.st_size == 0)) { noseek(); return; }