aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2023-05-27 05:41:57 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2023-05-27 05:43:21 +0000
commit03a8680202ef7d7e68adc70625633c490b4ed637 (patch)
treef60297c3ebdaf766ef3635bd4c8e85c2f04b579e /sbin/fsck_ffs
parent52b63df9b6dfc157fb0b9f61a770b64e3663dee9 (diff)
downloadsrc-03a8680202ef7d7e68adc70625633c490b4ed637.tar.gz
src-03a8680202ef7d7e68adc70625633c490b4ed637.zip
Correct two bugs in fsck_ffs(8) triggered by corrupted filesystems.
Always create a directory inode structure when a directory inode is found in Pass 1 as it is not known whether it will be saved or removed in later passes. If it is to be saved the directory inode structure is needed to track its status and fsck_ffs(8) will segment fault if it does not exist. Reported-by: Robert Morris PR: 271310 PR: 271354 MFC-after: 1 week Sponsored-by: The FreeBSD Foundation
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/pass1.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index e784fd29dc1c..863bf34ff0fc 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -400,13 +400,13 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuiltcg)
if (mode == IFDIR) {
if (DIP(dp, di_size) == 0) {
inoinfo(inumber)->ino_state = DCLEAR;
- } else if (DIP(dp, di_nlink) <= 0) {
+ } else if (DIP(dp, di_nlink) == 0) {
inoinfo(inumber)->ino_state = DZLINK;
} else {
inoinfo(inumber)->ino_state = DSTATE;
- cacheino(dp, inumber);
- countdirs++;
}
+ cacheino(dp, inumber);
+ countdirs++;
} else if (DIP(dp, di_nlink) <= 0)
inoinfo(inumber)->ino_state = FZLINK;
else