summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2014-06-09 09:13:33 +0000
committertobias <tobias@openbsd.org>2014-06-09 09:13:33 +0000
commite15dfc065d29f3de1d76437c33b7d4c5e07e6f48 (patch)
treec021b2e438885e450f7d1d098a0d37ea91f43206
parentcheck both rsdp checksums in the case of rsdp revision >= 2. (diff)
downloadwireguard-openbsd-e15dfc065d29f3de1d76437c33b7d4c5e07e6f48.tar.xz
wireguard-openbsd-e15dfc065d29f3de1d76437c33b7d4c5e07e6f48.zip
Fix possible out of boundary access if filesystem is full or corrupt.
Merged from Android (commit id 59ae828834dc177c74775cf36cafda4da9927bd9). ok deraadt@
-rw-r--r--sbin/fsck_msdos/fat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/fsck_msdos/fat.c b/sbin/fsck_msdos/fat.c
index 07789da8810..8d39e1a61b8 100644
--- a/sbin/fsck_msdos/fat.c
+++ b/sbin/fsck_msdos/fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fat.c,v 1.18 2009/10/27 23:59:33 deraadt Exp $ */
+/* $OpenBSD: fat.c,v 1.19 2014/06/09 09:13:33 tobias Exp $ */
/* $NetBSD: fat.c,v 1.8 1997/10/17 11:19:53 ws Exp $ */
/*
@@ -535,7 +535,8 @@ checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat)
ret = 1;
}
}
- if (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE) {
+ if (boot->NumFree && (boot->FSNext >= boot->NumClusters ||
+ fat[boot->FSNext].next != CLUST_FREE)) {
pwarn("Next free cluster in FSInfo block (%u) not free\n",
boot->FSNext);
if (ask(1, "fix"))