From nobody Thu Jan 04 08:23:11 2024 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 4T5KNH6BPqz563DH; Thu, 4 Jan 2024 08:23:11 +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 4T5KNH5W8dz4gdk; Thu, 4 Jan 2024 08:23:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704356591; 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=ejhHli/beqvE+eYEwasfFzGIUdzqvEETZXf7Pn1/wyk=; b=C9fYCtLdwzwzmRTNXoUwOqClWffFsqgYDorTpWje6qaml1dI3xEOrVcZfyIxsKjzc2xkqB L+noc8gilBo/F/qHALN3+HS0Iiz2Oy47btXMR6345IUF2+LPQu9woxoiH3wFSyAaHLIhPi +BLMWgbMC+mmbwIlT8y4btF8fcMAo0STjMeWJSGaq/zYTL/+QwA2llmqnfa0F07msLuMSz ZWv6Kh3tlItyyHVEGX3WWPgqAuj/kAfv9gDB/mpPWR4Hhy4Prsi/DwfrRxggXuAp5NL8Xh dyD+MaRjqsvAzY/QhutGnS7wBLIzTP4yuhUsGwOJxSdpL/PeuLTTjDkAFCVBIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704356591; 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=ejhHli/beqvE+eYEwasfFzGIUdzqvEETZXf7Pn1/wyk=; b=LSw+XfhkaorcRfiXP1eUAkyo2Sqrd/8VwBU6gt+LaJ2qk5lfVvDlgRvWWBrD8Z3PY2Hxjg aadg+pJ/xSQsGPwA1RPnpRmpHTmXO+Ad2pv2zsto7RVgir1JM+K3GLqwO/8oPl4G9j/qGv 41VhA0CoFT12it78YOBLMqXxeUCmBIb+am5+ifDxowC5KG01rZC6VrJm8GNOUBgThFQHDQ 3Mjzk4EF4WE1EmxmxsveNmQuIEzZc42RyW6I+Q3zLpY+/Kb1CqpVyyI6irb896IO0al4SA scns+IcDp33w6Cgc4xdwybY202o59K3XuFntZA6/VH87MX5DHqoOVdB4whB16A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704356591; a=rsa-sha256; cv=none; b=X4R4tZ2jJB7szoyn4qPz4xc/kTkTxd6our2ny3+FNCHPfkkF1WdIsckGB2IUzrUx/ADlFZ 9iDYP6BR5IyuxC8GLR2WGrIFpiICJY42y1Gdx10mY5XCxhKsse02SMYJW/Hb0IKK/XOCoO mrV3MfvSmNCy0sHXsXWrirJv0PMSIxrzV1MS3nXFYDGh4UWiT1eSB40JyiQTDiI75alIi3 HRF7tCxxRBg1GsQS3Y5bz/SCdpYpLwBHED3PDd+70kTbtl/+AOLAQN33LgKNtaeFHQyLwc fowqNjrJbePQBSIfukC14M/x5BRmJ556sxtSN8RgY+2QBtPrg1xT1eHPUN3zNg== 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 4T5KNH4Z0Xz1Kvc; Thu, 4 Jan 2024 08:23:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4048NBuT013220; Thu, 4 Jan 2024 08:23:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4048NBM8013217; Thu, 4 Jan 2024 08:23:11 GMT (envelope-from git) Date: Thu, 4 Jan 2024 08:23:11 GMT Message-Id: <202401040823.4048NBM8013217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: e23954bd42fe - main - hexdump: Do not trust st_size if it equals zero. 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: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e23954bd42fe4331b67ba8f6446bcccf751096f1 Auto-Submitted: auto-generated The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=e23954bd42fe4331b67ba8f6446bcccf751096f1 commit e23954bd42fe4331b67ba8f6446bcccf751096f1 Author: Ricardo Branco AuthorDate: 2024-01-03 20:17:58 +0000 Commit: Xin LI CommitDate: 2024-01-04 08:16:50 +0000 hexdump: Do not trust st_size if it equals zero. Fix for hexdump -s not being able to skip files residing in pseudo-filesystems that advertise a zero size value. Historically, many pseudofs-based filesystems (e.g., procfs) report a va_size of 0 for numerous files classified as regular files. Typically, the contents of these files are generated on demand from kernel data as sbuf(9) strings at the time they are read. Accurately reporting the size of these files is challenging, as it often involves generating their contents. These pseudofs implementations frequently report the size as 0. This is a historical behavior and also aligns with Linux behavior. To maintain compatibility, we have chosen to preserve the existing behavior and address it in the userland application, rather than modifying it in the kernel (by updating the correct value for va_size). PR: bin/276106 MFC after: 1 week --- 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 2bef03626fe2..77de580983ca 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -391,13 +391,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; }