diff options
author | pfg <pfg@FreeBSD.org> | 2014-07-14 20:58:02 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-07-14 20:58:02 +0000 |
commit | 375de29597d7642e00c3ba6d1b74ff1afea9671d (patch) | |
tree | 8d4f2a4674d7f649c46007a9844d2c1cf484cfe1 /sbin/fsck_msdosfs/dir.c | |
parent | 7716a7c65e3caa8b0092a81c281a64939bf12533 (diff) | |
download | FreeBSD-src-375de29597d7642e00c3ba6d1b74ff1afea9671d.zip FreeBSD-src-375de29597d7642e00c3ba6d1b74ff1afea9671d.tar.gz |
msdosfs: Assorted fixes from other BSDs.
When truncating cluster chains fix the length of the cluster head.
http://marc.info/?t=140304310700005&r=1&w=2
Avoid infinite loops in cluster chain linked lists.
http://marc.info/?l=openbsd-tech&m=140275150804337&w=2
Avoid off-by-one on FAT12 filesystems.
http://marc.info/?l=openbsd-tech&m=140234174104724&w=2
Obtained from: NetBSD (from OpenBSD)
MFC after: 1 week
Diffstat (limited to 'sbin/fsck_msdosfs/dir.c')
-rw-r--r-- | sbin/fsck_msdosfs/dir.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 6352ec5..e8d6475 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -419,13 +419,14 @@ checksize(struct bootblock *boot, struct fatEntry *fat, u_char *p, fullpath(dir)); if (ask(1, "Drop superfluous clusters")) { cl_t cl; - u_int32_t sz = 0; + u_int32_t sz, len; - for (cl = dir->head; (sz += boot->ClusterSize) < - dir->size;) + for (cl = dir->head, len = sz = 0; + (sz += boot->ClusterSize) < dir->size; len++) cl = fat[cl].next; clearchain(boot, fat, fat[cl].next); fat[cl].next = CLUST_EOF; + fat[dir->head].length = len; return FSFATMOD; } else return FSERROR; |