git: ff99541a14d7 - stable/13 - MFC: hexdump: Do not trust st_size if it equals zero.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 22 Dec 2024 07:49:58 UTC
The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=ff99541a14d7b8cf85e93774e939efde38a469b9 commit ff99541a14d7b8cf85e93774e939efde38a469b9 Author: Ricardo Branco <rbranco@suse.de> AuthorDate: 2024-01-03 20:17:58 +0000 Commit: Xin LI <delphij@FreeBSD.org> 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; }