dosfstools/0001-Avoid-returning-deleted-directory-entries-as-labels.patch

43 lines
1.5 KiB
Diff
Raw Normal View History

2019-09-30 10:37:32 -04:00
From 747c8f9522804a2fca43410acb700c4810a7c8a3 Mon Sep 17 00:00:00 2001
From: Andreas Bombe <aeb@debian.org>
Date: Sun, 1 Oct 2017 00:46:05 +0200
Subject: [PATCH 36/86] Avoid returning deleted directory entries as labels
In find_volume_de(), only the attributes were tested to decide whether a
directory entry was a volume label. This could lead to deleted entries
being returned. Check the name for deleted or unallocated marker to
prevent this.
Signed-off-by: Andreas Bombe <aeb@debian.org>
---
src/boot.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/boot.c b/src/boot.c
index 54febf5..bb47d41 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -530,7 +530,8 @@ off_t find_volume_de(DOS_FS * fs, DIR_ENT * de)
offset = cluster_start(fs, cluster);
for (i = 0; i * sizeof(DIR_ENT) < fs->cluster_size; i++) {
fs_read(offset, sizeof(DIR_ENT), de);
- if (de->attr != VFAT_LN_ATTR && de->attr & ATTR_VOLUME)
+ if (!IS_FREE(de->name) &&
+ de->attr != VFAT_LN_ATTR && de->attr & ATTR_VOLUME)
return offset;
offset += sizeof(DIR_ENT);
}
@@ -539,7 +540,8 @@ off_t find_volume_de(DOS_FS * fs, DIR_ENT * de)
for (i = 0; i < fs->root_entries; i++) {
offset = fs->root_start + i * sizeof(DIR_ENT);
fs_read(offset, sizeof(DIR_ENT), de);
- if (de->attr != VFAT_LN_ATTR && de->attr & ATTR_VOLUME)
+ if (!IS_FREE(de->name) &&
+ de->attr != VFAT_LN_ATTR && de->attr & ATTR_VOLUME)
return offset;
}
}
--
1.8.3.1