From nobody Sun Dec 22 07:49:58 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 4YGCx22tyDz5jDTL; Sun, 22 Dec 2024 07:49:58 +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 4YGCx22996z4hY2; Sun, 22 Dec 2024 07:49:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853798; 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=sQGVsfQvwiWSyhMSD+DK91Ue3/6iL8GHmSArvWuu02Q=; b=ggzf4msdj+/qAAumnichTzg9Y/1Le/QqeaQu79zb9Qw6UEovo7SheCR5+Xvd79DQw/jfKn sm6nJomis3aJjEXcN5xfhJP6ChFMhJbkGDCq/Kb3ApvyYZhFPMlOtfCwnLHQXyn9m7hMqt 83wBKGfN3hqlCmNj88kWwICIV8p9IfhgXTxke/1BZNu2nUhAGWRQfIhefcideWDJp1RDrj I5qRucnMadFFRFkYuWH5i3R/Y4Lgdlwg7Q5FeT9iwpqLmyRoC07deGjZir6JdgUhzLpe5a EfvxOCXsPUKiW6U9pTYuNi30aB4+Vbg6rRFI3gVe3CrY1nT6semgiamz+E27Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853798; 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=sQGVsfQvwiWSyhMSD+DK91Ue3/6iL8GHmSArvWuu02Q=; b=E9IxcXi4i6wpKmJYTe4HMUH5uYLkmvahIwtRXN2JrXAAip23aPfzPUhILKvXMmjadQsMPZ 3uBM5vY+3lnS8eML2nTwjo2XaeGCp4qPb1QGkrS4vOGtv2vr+EhtFRCl98zxaLkp9H+4zh 4JAD82v5xBapftEb166dBAjXUsOGDp/muRRXU+DjojI1aCio/FG10Rl9CP/Li7SxSIn6m9 4dee3tFZ8Fulo5vODYWZ3j0Q2VpjIfW+diXaszw8+AaU87yJqQHo4JXoDQVSBcvYcZJWMW Kv6Iupptev4JWwkXA8k4J9YA1HBN0vqO5NYXbgdCnKARLcH7/+tJGGiBeiluKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734853798; a=rsa-sha256; cv=none; b=M38MNR1uWtydZqx/l9Ot2nrMCJ6148uzFm2u4nox7j+YyOl6QwDMcVK1fCEKZtbqsKf+FA De7+z/9nv+/69An7GZXvbTf2RLA9lKwYgDFMT0k65PtGkReknuxw0Hh5DASOUKgtnAed+B 2v6AVD+izft9OAjAp2wO3hZmBmO9Ige0lxI6eK9dmX09ZYawnSTvwCFBO1BTNUxVfwwHY7 KVYkbOA1j5/6RCkkOIbjU2l1L/SWT80TbBUTZ3CeYXVAM2+j8Jbe3NgwZtdKLnTY4gQ94y awes5MLxOeClRAQg4WPIazozV0i9zO/z/7BjuZbGfJkoAr/a1paBy8p0oWQ8yQ== 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 4YGCx21nDSz10rc; Sun, 22 Dec 2024 07:49:58 +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 4BM7nwUh023743; Sun, 22 Dec 2024 07:49:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BM7nwFY023740; Sun, 22 Dec 2024 07:49:58 GMT (envelope-from git) Date: Sun, 22 Dec 2024 07:49:58 GMT Message-Id: <202412220749.4BM7nwFY023740@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: ff99541a14d7 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: ff99541a14d7b8cf85e93774e939efde38a469b9 Auto-Submitted: auto-generated The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=ff99541a14d7b8cf85e93774e939efde38a469b9 commit ff99541a14d7b8cf85e93774e939efde38a469b9 Author: Ricardo Branco AuthorDate: 2024-01-03 20:17:58 +0000 Commit: Xin LI CommitDate: 2024-12-22 07:49:50 +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 bdcb4ed28170..079c14e8f823 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -393,13 +393,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; }