git: 897d3ae91345 - main - stand: check for short reads in ufs

From: Ryan Libby <rlibby_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 17:54:04 UTC
The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=897d3ae913452b1832322da625a5dcc7b29ecfc6

commit 897d3ae913452b1832322da625a5dcc7b29ecfc6
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2026-11-09 17:15:55 +0000
Commit:     Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2026-11-09 17:15:55 +0000

    stand: check for short reads in ufs
    
    Reviewed by:    imp, jhb
    Differential Revision:  https://reviews.freebsd.org/D59379
---
 stand/libsa/ufs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/stand/libsa/ufs.c b/stand/libsa/ufs.c
index 67d414b217c9..9c7c73c6634a 100644
--- a/stand/libsa/ufs.c
+++ b/stand/libsa/ufs.c
@@ -363,6 +363,8 @@ buf_write_file(struct open_file *f, const char *buf_p, size_t *size_p)
 			block_size, fp->f_buf, &fp->f_buf_size);
 		if (rc)
 			return (rc);
+		if (fp->f_buf_size != block_size)
+			return (EIO);
 
 		fp->f_buf_blkno = file_block;
 	}
@@ -420,6 +422,8 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
 				block_size, fp->f_buf, &fp->f_buf_size);
 			if (rc)
 				return (rc);
+			if (fp->f_buf_size != block_size)
+				return (EIO);
 		}
 
 		fp->f_buf_blkno = file_block;
@@ -663,6 +667,10 @@ ufs_open(const char *upath, struct open_file *f)
 					fs->fs_bsize, buf, &buf_size);
 				if (rc)
 					goto out;
+				if (buf_size != fs->fs_bsize) {
+					rc = EIO;
+					goto out;
+				}
 
 				bcopy((char *)buf, namebuf, (unsigned)link_len);
 			}