The branch stable/14 has been updated by delphij:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=538bf98c7c3ad65b6fa70cadd86635139c689097

commit 538bf98c7c3ad65b6fa70cadd86635139c689097
Author:     Ricardo Branco <rbra...@suse.de>
AuthorDate: 2024-01-03 20:17:58 +0000
Commit:     Xin LI <delp...@freebsd.org>
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;
        }

Reply via email to