From 56580f3f6d0ef8e9ae73160f4eea5d6d22d711b3 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 14 Dec 2017 07:55:11 +0000 Subject: [PATCH] MFC r326391: Prevent OOB access on corrupted msdos directories. Submitted by: Veo Zhang --- sbin/fsck_msdosfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 8e7fe4d29a03..20910216af28 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -619,7 +619,7 @@ readDosDirSection(int f, struct bootblock *boot, struct fatEntry *fat, dirent.name[8] = '\0'; for (k = 7; k >= 0 && dirent.name[k] == ' '; k--) dirent.name[k] = '\0'; - if (dirent.name[k] != '\0') + if (k < 0 || dirent.name[k] != '\0') k++; if (dirent.name[0] == SLOT_E5) dirent.name[0] = 0xe5;