git: 52f50301aaab - stable/13 - Correct two bugs in fsck_ffs(8) triggered by corrupted filesystems.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Wed, 07 Jun 2023 23:15:34 UTC
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=52f50301aaabddc6e3c1bc8c354101cfd7ea0463

commit 52f50301aaabddc6e3c1bc8c354101cfd7ea0463
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-05-27 05:41:57 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-06-07 22:40:35 +0000

    Correct two bugs in fsck_ffs(8) triggered by corrupted filesystems.
    
    Reported-by:  Robert Morris
    PR:           271310
    PR:           271354
    Sponsored-by: The FreeBSD Foundation
    
    (cherry picked from commit 03a8680202ef7d7e68adc70625633c490b4ed637)
---
 sbin/fsck_ffs/pass1.c | 6 +++---
 1 file 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