Update to dosfstools-4.2
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
This commit is contained in:
parent
2216938f65
commit
943efa80b4
@ -1,30 +0,0 @@
|
|||||||
From ed9facfbb0fa33e70ab95c21d49525f4f96224e2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jakub Wilk <jwilk@jwilk.net>
|
|
||||||
Date: Tue, 11 Jul 2017 01:01:20 +0200
|
|
||||||
Subject: [PATCH 25/86] Fix signed integer overflow in FSTART
|
|
||||||
|
|
||||||
uint16_t was promoted to int, and then left shift could overflow it.
|
|
||||||
Add explicit cast to uint32_t to avoid undefined behavior.
|
|
||||||
|
|
||||||
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
|
|
||||||
Signed-off-by: Andreas Bombe <aeb@debian.org>
|
|
||||||
---
|
|
||||||
src/check.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/check.c b/src/check.c
|
|
||||||
index 0db301d..a2a752f 100644
|
|
||||||
--- a/src/check.c
|
|
||||||
+++ b/src/check.c
|
|
||||||
@@ -47,7 +47,7 @@ static DOS_FILE *root;
|
|
||||||
/* get start field of a dir entry */
|
|
||||||
#define FSTART(p,fs) \
|
|
||||||
((uint32_t)le16toh(p->dir_ent.start) | \
|
|
||||||
- (fs->fat_bits == 32 ? le16toh(p->dir_ent.starthi) << 16 : 0))
|
|
||||||
+ (fs->fat_bits == 32 ? (uint32_t)le16toh(p->dir_ent.starthi) << 16 : 0))
|
|
||||||
|
|
||||||
#define MODIFY(p,i,v) \
|
|
||||||
do { \
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
From 87a8f29785bb605350821f1638a42e6cf3e49ce3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Will Newton <willn@resin.io>
|
|
||||||
Date: Thu, 31 Aug 2017 10:42:13 +0100
|
|
||||||
Subject: [PATCH 49/86] src/check.c: Fix up mtools created bad dir entries
|
|
||||||
|
|
||||||
mtools writes uninitialized data to the case field of some
|
|
||||||
directory entries. Running fsck.fat on these filesystems
|
|
||||||
will cause the directory to get deleted which can lead to
|
|
||||||
data loss. Detect this situation and clear the flag instead.
|
|
||||||
|
|
||||||
mtools patch to fix the original issue:
|
|
||||||
|
|
||||||
https://lists.gnu.org/archive/html/info-mtools/2014-08/msg00000.html
|
|
||||||
|
|
||||||
Signed-off-by: Will Newton <willn@resin.io>
|
|
||||||
---
|
|
||||||
src/check.c | 7 +++++++
|
|
||||||
1 file changed, 7 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/check.c b/src/check.c
|
|
||||||
index a2a752f..f1e18be 100644
|
|
||||||
--- a/src/check.c
|
|
||||||
+++ b/src/check.c
|
|
||||||
@@ -495,6 +495,13 @@ static int handle_dot(DOS_FS * fs, DOS_FILE * file, int dots)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ if (file->dir_ent.lcase & FAT_NO_83NAME) {
|
|
||||||
+ /* Some versions of mtools write these directory entries with random data in
|
|
||||||
+ this field. */
|
|
||||||
+ printf("%s\n Is a dot with no 8.3 name flag set, clearing.\n", path_name(file));
|
|
||||||
+ file->dir_ent.lcase &= ~FAT_NO_83NAME;
|
|
||||||
+ MODIFY(file, lcase, file->dir_ent.lcase);
|
|
||||||
+ }
|
|
||||||
if (!dots) {
|
|
||||||
printf("Root contains directory \"%s\". Dropping it.\n", name);
|
|
||||||
drop_file(fs, file);
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
From 4f953bb5d74e0eeda6cbee1e4871513edc7b912b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andreas Bombe <aeb@debian.org>
|
|
||||||
Date: Mon, 11 Jun 2018 14:21:17 +0200
|
|
||||||
Subject: [PATCH 68/86] Remove long file name when changing short file name
|
|
||||||
|
|
||||||
In the current state, long file names are poorly supported and in case
|
|
||||||
the file got automatically or manually renamed in auto_rename() or
|
|
||||||
rename_file(), only the short file name would be manipulated.
|
|
||||||
|
|
||||||
Only the checksum would be fixed to have the LFN stay valid. This would
|
|
||||||
cause issues such as the rename being hidden by the unchanged LFN or
|
|
||||||
duplicate LFNs remaining if they were the cause for a rename.
|
|
||||||
|
|
||||||
Change so that existing LFNs are removed for files being renamed.
|
|
||||||
---
|
|
||||||
src/check.c | 14 ++++++++------
|
|
||||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/check.c b/src/check.c
|
|
||||||
index 49dd427..76c9c3d 100644
|
|
||||||
--- a/src/check.c
|
|
||||||
+++ b/src/check.c
|
|
||||||
@@ -293,9 +293,10 @@ static void auto_rename(DOS_FILE * file)
|
|
||||||
} else {
|
|
||||||
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
|
||||||
}
|
|
||||||
- if (file->lfn)
|
|
||||||
- lfn_fix_checksum(file->lfn_offset, file->offset,
|
|
||||||
- (const char *)file->dir_ent.name);
|
|
||||||
+ if (file->lfn) {
|
|
||||||
+ lfn_remove(file->lfn_offset, file->offset);
|
|
||||||
+ file->lfn = NULL;
|
|
||||||
+ }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
number++;
|
|
||||||
@@ -334,9 +335,10 @@ static void rename_file(DOS_FILE * file)
|
|
||||||
} else {
|
|
||||||
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
|
||||||
}
|
|
||||||
- if (file->lfn)
|
|
||||||
- lfn_fix_checksum(file->lfn_offset, file->offset,
|
|
||||||
- (const char *)file->dir_ent.name);
|
|
||||||
+ if (file->lfn) {
|
|
||||||
+ lfn_remove(file->lfn_offset, file->offset);
|
|
||||||
+ file->lfn = NULL;
|
|
||||||
+ }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
From fb0cc0df4ce3d349796ce4960c4e32d16532b203 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andreas Bombe <aeb@debian.org>
|
|
||||||
Date: Tue, 14 Aug 2018 12:58:58 +0200
|
|
||||||
Subject: [PATCH 71/86] Fix gcc sprintf() length warnings
|
|
||||||
|
|
||||||
There are two sprintf() calls that receive warnings from current
|
|
||||||
versions of gcc for possibly overrunning the temporary buffers they're
|
|
||||||
writing into.
|
|
||||||
|
|
||||||
The first one in src/check.c is theoretically safe since strftime()
|
|
||||||
shouldn't generate such a long string. Reduce the maximum length of the
|
|
||||||
strftime() string to fix this warning. Also detect strftime() errors
|
|
||||||
and overwrite the buffer with a message in that case.
|
|
||||||
|
|
||||||
The second one in src/boot.c should not be possible and is a limitation
|
|
||||||
of gcc's detection. It assumes that %02x could write up to 8
|
|
||||||
characters, even though the arguments are pointers to uint8_t which
|
|
||||||
can't be more than two characters. Placate gcc by lengthening the
|
|
||||||
temporary buffer by 12 bytes.
|
|
||||||
---
|
|
||||||
src/boot.c | 2 +-
|
|
||||||
src/check.c | 5 +++--
|
|
||||||
2 files changed, 4 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/boot.c b/src/boot.c
|
|
||||||
index 947703c..bedd45a 100644
|
|
||||||
--- a/src/boot.c
|
|
||||||
+++ b/src/boot.c
|
|
||||||
@@ -297,7 +297,7 @@ static void check_backup_boot(DOS_FS * fs, struct boot_sector *b, unsigned int l
|
|
||||||
/* there are any differences */
|
|
||||||
uint8_t *p, *q;
|
|
||||||
int i, pos, first = 1;
|
|
||||||
- char buf[20];
|
|
||||||
+ char buf[32];
|
|
||||||
|
|
||||||
printf("There are differences between boot sector and its backup.\n");
|
|
||||||
printf("This is mostly harmless. Differences: (offset:original/backup)\n ");
|
|
||||||
diff --git a/src/check.c b/src/check.c
|
|
||||||
index 76c9c3d..13a5fd6 100644
|
|
||||||
--- a/src/check.c
|
|
||||||
+++ b/src/check.c
|
|
||||||
@@ -137,13 +137,14 @@ static char *file_stat(DOS_FILE * file)
|
|
||||||
{
|
|
||||||
static char temp[100];
|
|
||||||
struct tm *tm;
|
|
||||||
- char tmp[100];
|
|
||||||
+ char tmp[40];
|
|
||||||
time_t date;
|
|
||||||
|
|
||||||
date =
|
|
||||||
date_dos2unix(le16toh(file->dir_ent.time), le16toh(file->dir_ent.date));
|
|
||||||
tm = localtime(&date);
|
|
||||||
- strftime(tmp, 99, "%H:%M:%S %b %d %Y", tm);
|
|
||||||
+ if (!strftime(tmp, 40, "%H:%M:%S %b %d %Y", tm))
|
|
||||||
+ strcpy(tmp, "<internal format error>");
|
|
||||||
sprintf(temp, " Size %u bytes, date %s", le32toh(file->dir_ent.size), tmp);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
From 607fbed2534cb80063395936384f4aef293812fd Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
|
||||||
Date: Tue, 14 Aug 2018 20:57:27 +0200
|
|
||||||
Subject: [PATCH 72/86] fsck.fat: Fix Year 2038 Bug
|
|
||||||
|
|
||||||
Do not use time_t type and strftime() function which are affected by the
|
|
||||||
Year 2038 Bug. Instead parse date/time directly from DOS format which
|
|
||||||
avoids conversion from DOS to UNIX + conversion from UNIX to string.
|
|
||||||
---
|
|
||||||
src/check.c | 55 +++++++++++++++++++++----------------------------------
|
|
||||||
1 file changed, 21 insertions(+), 34 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/check.c b/src/check.c
|
|
||||||
index 13a5fd6..76e9721 100644
|
|
||||||
--- a/src/check.c
|
|
||||||
+++ b/src/check.c
|
|
||||||
@@ -108,44 +108,31 @@ static char *path_name(DOS_FILE * file)
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static const int day_n[] =
|
|
||||||
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0 };
|
|
||||||
-/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
|
|
||||||
-
|
|
||||||
-/* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
|
|
||||||
-
|
|
||||||
-static time_t date_dos2unix(unsigned short time, unsigned short date)
|
|
||||||
-{
|
|
||||||
- int month, year;
|
|
||||||
- time_t secs;
|
|
||||||
-
|
|
||||||
- month = ((date >> 5) & 15) - 1;
|
|
||||||
- if (month < 0) {
|
|
||||||
- /* make sure that nothing bad happens if the month bits were zero */
|
|
||||||
- month = 0;
|
|
||||||
- }
|
|
||||||
- year = date >> 9;
|
|
||||||
- secs =
|
|
||||||
- (time & 31) * 2 + 60 * ((time >> 5) & 63) + (time >> 11) * 3600 +
|
|
||||||
- 86400 * ((date & 31) - 1 + day_n[month] + (year / 4) + year * 365 -
|
|
||||||
- ((year & 3) == 0 && month < 2 ? 1 : 0) + 3653);
|
|
||||||
- /* days since 1.1.70 plus 80's leap day */
|
|
||||||
- return secs;
|
|
||||||
-}
|
|
||||||
+static const char *month_str[] =
|
|
||||||
+ { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
|
||||||
|
|
||||||
static char *file_stat(DOS_FILE * file)
|
|
||||||
{
|
|
||||||
static char temp[100];
|
|
||||||
- struct tm *tm;
|
|
||||||
- char tmp[40];
|
|
||||||
- time_t date;
|
|
||||||
-
|
|
||||||
- date =
|
|
||||||
- date_dos2unix(le16toh(file->dir_ent.time), le16toh(file->dir_ent.date));
|
|
||||||
- tm = localtime(&date);
|
|
||||||
- if (!strftime(tmp, 40, "%H:%M:%S %b %d %Y", tm))
|
|
||||||
- strcpy(tmp, "<internal format error>");
|
|
||||||
- sprintf(temp, " Size %u bytes, date %s", le32toh(file->dir_ent.size), tmp);
|
|
||||||
+ unsigned int hours, minutes, secs, day, month, year;
|
|
||||||
+ unsigned short time, date;
|
|
||||||
+
|
|
||||||
+ time = le16toh(file->dir_ent.time);
|
|
||||||
+ date = le16toh(file->dir_ent.date);
|
|
||||||
+ year = 1980 + (date >> 9);
|
|
||||||
+ month = ((date >> 5) & 15);
|
|
||||||
+ if (month < 1) month = 1;
|
|
||||||
+ else if (month > 12) month = 12;
|
|
||||||
+ day = (date & 31);
|
|
||||||
+ if (day < 1) day = 1;
|
|
||||||
+ hours = (time >> 11);
|
|
||||||
+ if (hours > 23) hours = 23;
|
|
||||||
+ minutes = ((time >> 5) & 63);
|
|
||||||
+ if (minutes > 59) minutes = 59;
|
|
||||||
+ secs = (time & 31) * 2;
|
|
||||||
+ if (secs > 59) secs = 59;
|
|
||||||
+ sprintf(temp, " Size %u bytes, date %02u:%02u:%02u %s %02u %4u",
|
|
||||||
+ le32toh(file->dir_ent.size), hours, minutes, secs, month_str[month-1], day, year);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
From 086e13c72651439f39f678ffefb4f78b0c0fb758 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
|
||||||
Date: Sun, 12 Aug 2018 12:15:21 +0200
|
|
||||||
Subject: [PATCH 82/86] mkfs.fat: Fix parsing of block number
|
|
||||||
|
|
||||||
Block number must not be negative. It is 32bit so use long long type and
|
|
||||||
strtoll() function to ensure that converted positive 32bit value would fit
|
|
||||||
into type.
|
|
||||||
---
|
|
||||||
src/mkfs.fat.c | 12 ++++++------
|
|
||||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
|
|
||||||
index 660b6ba..70f13c1 100644
|
|
||||||
--- a/src/mkfs.fat.c
|
|
||||||
+++ b/src/mkfs.fat.c
|
|
||||||
@@ -417,7 +417,7 @@ static void get_list_blocks(char *filename)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
FILE *listfile;
|
|
||||||
- long blockno;
|
|
||||||
+ long long blockno;
|
|
||||||
char *line = NULL;
|
|
||||||
size_t linesize = 0;
|
|
||||||
int lineno = 0;
|
|
||||||
@@ -439,9 +439,9 @@ static void get_list_blocks(char *filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
- blockno = strtol(line, &end, 10);
|
|
||||||
+ blockno = strtoll(line, &end, 10);
|
|
||||||
|
|
||||||
- if (errno) {
|
|
||||||
+ if (errno || blockno < 0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"While converting bad block number in line %d: %s\n",
|
|
||||||
lineno, strerror(errno));
|
|
||||||
@@ -466,16 +466,16 @@ static void get_list_blocks(char *filename)
|
|
||||||
|
|
||||||
/* Mark all of the sectors in the block as bad */
|
|
||||||
for (i = 0; i < SECTORS_PER_BLOCK; i++) {
|
|
||||||
- unsigned long sector = blockno * SECTORS_PER_BLOCK + i;
|
|
||||||
+ unsigned long long sector = blockno * SECTORS_PER_BLOCK + i;
|
|
||||||
|
|
||||||
if (sector < start_data_sector) {
|
|
||||||
- fprintf(stderr, "Block number %ld is before data area\n",
|
|
||||||
+ fprintf(stderr, "Block number %lld is before data area\n",
|
|
||||||
blockno);
|
|
||||||
die("Error in bad blocks file");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sector >= num_sectors) {
|
|
||||||
- fprintf(stderr, "Block number %ld is behind end of filesystem\n",
|
|
||||||
+ fprintf(stderr, "Block number %lld is behind end of filesystem\n",
|
|
||||||
blockno);
|
|
||||||
die("Error in bad blocks file");
|
|
||||||
}
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
From af3e50dbe29e6ecf5ada3ff4dad12ac19f426d8d Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
|
||||||
Date: Sun, 12 Aug 2018 12:15:45 +0200
|
|
||||||
Subject: [PATCH 83/86] device_info: Fix parsing partition number
|
|
||||||
|
|
||||||
Ensures that it is always valid number which does not overflow or
|
|
||||||
underflow.
|
|
||||||
---
|
|
||||||
src/device_info.c | 9 ++++++---
|
|
||||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/device_info.c b/src/device_info.c
|
|
||||||
index cd57388..a8764d7 100644
|
|
||||||
--- a/src/device_info.c
|
|
||||||
+++ b/src/device_info.c
|
|
||||||
@@ -44,6 +44,8 @@
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <ctype.h>
|
|
||||||
|
|
||||||
#include "blkdev.h"
|
|
||||||
#include "device_info.h"
|
|
||||||
@@ -109,7 +111,7 @@ static int udev_fill_info(struct device_info *info, struct stat *stat)
|
|
||||||
char holders_path[PATH_MAX + 1];
|
|
||||||
DIR *holders_dir;
|
|
||||||
struct dirent *dir_entry;
|
|
||||||
- unsigned long number;
|
|
||||||
+ long number;
|
|
||||||
char *endptr;
|
|
||||||
|
|
||||||
if (device_info_verbose >= 3)
|
|
||||||
@@ -227,8 +229,9 @@ static int udev_fill_info(struct device_info *info, struct stat *stat)
|
|
||||||
if (device_info_verbose >= 3)
|
|
||||||
printf("attribute \"partition\" is \"%s\"\n", attr);
|
|
||||||
|
|
||||||
- number = strtoul(attr, &endptr, 10);
|
|
||||||
- if (!*endptr)
|
|
||||||
+ errno = 0;
|
|
||||||
+ number = strtol(attr, &endptr, 10);
|
|
||||||
+ if (*attr && !isspace(*attr) && !*endptr && !errno && number >= 0 && number <= INT_MAX)
|
|
||||||
info->partition = number;
|
|
||||||
} else {
|
|
||||||
printf("attribute \"partition\" not found\n");
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
From 1a1ba0053830b98e99f9b2713f64dbcb36e2a6cd Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
|
||||||
Date: Sun, 18 Nov 2018 20:47:29 +0100
|
|
||||||
Subject: [PATCH] Fix memory leaks in read_fat() function
|
|
||||||
|
|
||||||
Function read_fat() allocates memory to the user supplied buffer. Therefore
|
|
||||||
that function needs complement function for releasing allocated memory and
|
|
||||||
user needs to call if after finish its work.
|
|
||||||
|
|
||||||
This patch fixes memory leaks in fsck.fat and fatlabel tools.
|
|
||||||
|
|
||||||
Conflicts:
|
|
||||||
src/fsck.fat.c
|
|
||||||
src/fatlabel.c
|
|
||||||
[Zhiqiang Liu <liuzhiqiang26@huawei.com> modifies context]
|
|
||||||
|
|
||||||
Fixes #13
|
|
||||||
---
|
|
||||||
src/fat.c | 17 +++++++++++------
|
|
||||||
src/fat.h | 5 +++++
|
|
||||||
src/fsck.fat.c | 1 +
|
|
||||||
3 files changed, 17 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/fat.c b/src/fat.c
|
|
||||||
index d994e8e..849c758 100644
|
|
||||||
--- a/src/fat.c
|
|
||||||
+++ b/src/fat.c
|
|
||||||
@@ -75,6 +75,16 @@ void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void release_fat(DOS_FS * fs)
|
|
||||||
+{
|
|
||||||
+ if (fs->fat)
|
|
||||||
+ free(fs->fat);
|
|
||||||
+ if (fs->cluster_owner)
|
|
||||||
+ free(fs->cluster_owner);
|
|
||||||
+ fs->fat = NULL;
|
|
||||||
+ fs->cluster_owner = NULL;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Build a bookkeeping structure from the partition's FAT table.
|
|
||||||
* If the partition has multiple FATs and they don't agree, try to pick a winner,
|
|
||||||
@@ -92,12 +102,7 @@ void read_fat(DOS_FS * fs)
|
|
||||||
uint32_t total_num_clusters;
|
|
||||||
|
|
||||||
/* Clean up from previous pass */
|
|
||||||
- if (fs->fat)
|
|
||||||
- free(fs->fat);
|
|
||||||
- if (fs->cluster_owner)
|
|
||||||
- free(fs->cluster_owner);
|
|
||||||
- fs->fat = NULL;
|
|
||||||
- fs->cluster_owner = NULL;
|
|
||||||
+ release_fat(fs);
|
|
||||||
|
|
||||||
total_num_clusters = fs->data_clusters + 2;
|
|
||||||
eff_size = (total_num_clusters * fs->fat_bits + 7) / 8ULL;
|
|
||||||
diff --git a/src/fat.h b/src/fat.h
|
|
||||||
index 5c77634..f9b7643 100644
|
|
||||||
--- a/src/fat.h
|
|
||||||
+++ b/src/fat.h
|
|
||||||
@@ -28,6 +28,11 @@ void read_fat(DOS_FS * fs);
|
|
||||||
/* Loads the FAT of the filesystem described by FS. Initializes the FAT,
|
|
||||||
replaces broken FATs and rejects invalid cluster entries. */
|
|
||||||
|
|
||||||
+void release_fat(DOS_FS * fs);
|
|
||||||
+
|
|
||||||
+/* Release the FAT of the filesystem described by FS and free allocated memory.
|
|
||||||
+ Call it after finish work with FAT. */
|
|
||||||
+
|
|
||||||
void get_fat(FAT_ENTRY * entry, void *fat, uint32_t cluster, DOS_FS * fs);
|
|
||||||
|
|
||||||
/* Retrieve the FAT entry (next chained cluster) for CLUSTER. */
|
|
||||||
diff --git a/src/fsck.fat.c b/src/fsck.fat.c
|
|
||||||
index c244aba..b1aafe9 100644
|
|
||||||
--- a/src/fsck.fat.c
|
|
||||||
+++ b/src/fsck.fat.c
|
|
||||||
@@ -203,6 +203,7 @@ int main(int argc, char **argv)
|
|
||||||
reclaim_free(&fs);
|
|
||||||
qfree(&mem_queue);
|
|
||||||
}
|
|
||||||
+ release_fat(&fs);
|
|
||||||
|
|
||||||
exit:
|
|
||||||
if (fs_changed()) {
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
From 08cf67bb19f8b9cce0c2dd03432951ade476dadd Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andreas Bombe <aeb@debian.org>
|
|
||||||
Date: Thu, 26 Jan 2017 21:31:03 +0100
|
|
||||||
Subject: [PATCH] Turn label in struct DOS_FS into char array from pointer
|
|
||||||
|
|
||||||
Signed-off-by: Andreas Bombe <aeb@debian.org>
|
|
||||||
---
|
|
||||||
src/boot.c | 6 +-----
|
|
||||||
src/fatlabel.c | 2 +-
|
|
||||||
src/fsck.fat.h | 2 +-
|
|
||||||
3 files changed, 3 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/boot.c b/src/boot.c
|
|
||||||
index 58b4286..b4a3300 100644
|
|
||||||
--- a/src/boot.c
|
|
||||||
+++ b/src/boot.c
|
|
||||||
@@ -435,18 +435,14 @@ void read_boot(DOS_FS * fs)
|
|
||||||
fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
|
|
||||||
fs->fat_size = fat_length * logical_sector_size;
|
|
||||||
|
|
||||||
- fs->label = calloc(12, sizeof(uint8_t));
|
|
||||||
+ fs->label[0] = 0;
|
|
||||||
if (fs->fat_bits == 12 || fs->fat_bits == 16) {
|
|
||||||
struct boot_sector_16 *b16 = (struct boot_sector_16 *)&b;
|
|
||||||
if (b16->extended_sig == 0x29)
|
|
||||||
memmove(fs->label, b16->label, 11);
|
|
||||||
- else
|
|
||||||
- fs->label = NULL;
|
|
||||||
} else if (fs->fat_bits == 32) {
|
|
||||||
if (b.extended_sig == 0x29)
|
|
||||||
memmove(fs->label, &b.label, 11);
|
|
||||||
- else
|
|
||||||
- fs->label = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
total_fat_entries = (uint64_t)fs->fat_size * 8 / fs->fat_bits;
|
|
||||||
diff --git a/src/fatlabel.c b/src/fatlabel.c
|
|
||||||
index 9268ddb..cd3d2ee 100644
|
|
||||||
--- a/src/fatlabel.c
|
|
||||||
+++ b/src/fatlabel.c
|
|
||||||
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|
||||||
if (!rw) {
|
|
||||||
offset = find_volume_de(&fs, &de);
|
|
||||||
if (offset == 0)
|
|
||||||
- fprintf(stdout, "%s\n", fs.label);
|
|
||||||
+ fprintf(stdout, "%11s\n", fs.label);
|
|
||||||
else
|
|
||||||
fprintf(stdout, "%.8s%.3s\n", de.name, de.name + 8);
|
|
||||||
exit(0);
|
|
||||||
diff --git a/src/fsck.fat.h b/src/fsck.fat.h
|
|
||||||
index 5e93178..e91437d 100644
|
|
||||||
--- a/src/fsck.fat.h
|
|
||||||
+++ b/src/fsck.fat.h
|
|
||||||
@@ -164,7 +164,7 @@ typedef struct {
|
|
||||||
off_t backupboot_start; /* 0 if not present */
|
|
||||||
unsigned char *fat;
|
|
||||||
DOS_FILE **cluster_owner;
|
|
||||||
- char *label;
|
|
||||||
+ char label[11];
|
|
||||||
} DOS_FS;
|
|
||||||
|
|
||||||
extern int interactive, rw, list, verbose, test, write_immed;
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
Binary file not shown.
BIN
dosfstools-4.2.tar.gz
Normal file
BIN
dosfstools-4.2.tar.gz
Normal file
Binary file not shown.
@ -1,24 +1,13 @@
|
|||||||
Name: dosfstools
|
Name: dosfstools
|
||||||
Version: 4.1
|
Version: 4.2
|
||||||
Release: 11
|
Release: 1
|
||||||
Summary: FAT file system userspace tools
|
Summary: FAT file system userspace tools
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
URL: http://www.github.com/dosfstools/dosfstools
|
URL: http://www.github.com/dosfstools/dosfstools
|
||||||
Source0: http://www.github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.xz
|
Source0: http://www.github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
BuildRequires: gcc autoconf automake
|
BuildRequires: gcc autoconf automake
|
||||||
|
|
||||||
Patch0: 0000-Fix-signed-integer-overflow-in-FSTART.patch
|
|
||||||
Patch1: 0001-Avoid-returning-deleted-directory-entries-as-labels.patch
|
|
||||||
Patch2: 0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch
|
|
||||||
Patch3: 0003-Remove-long-file-name-when-changing-short-file-name.patch
|
|
||||||
Patch4: 0004-Fix-gcc-sprintf-length-warnings.patch
|
|
||||||
Patch5: 0005-fsck.fat-Fix-Year-2038-Bug.patch
|
|
||||||
Patch6: 0006-mkfs.fat-Fix-parsing-of-block-number.patch
|
|
||||||
Patch7: 0007-device_info-Fix-parsing-partition-number.patch
|
|
||||||
Patch8: 0008-Fix-memory-leaks-in-read_fat-function.patch
|
|
||||||
Patch9: 0009-Turn-label-in-struct-DOS_FS-into-char-array-from-poi.patch
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to
|
The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to
|
||||||
create, check and label FAT family file systems.
|
create, check and label FAT family file systems.
|
||||||
@ -45,15 +34,19 @@ make check
|
|||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%doc doc/* ChangeLog
|
%doc NEWS README doc/* ChangeLog
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%{_sbindir}/*
|
%{_sbindir}/*
|
||||||
|
%exclude %{_docdir}/%{name}/COPYING
|
||||||
|
|
||||||
|
|
||||||
%files help
|
%files help
|
||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 17 2021 Wenchao Hao <haowenchao@huawei.com> - 4.2-1
|
||||||
|
- Update to dosfstools-4.2
|
||||||
|
|
||||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 4.1-11
|
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 4.1-11
|
||||||
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user