diff --git a/0000-Fix-signed-integer-overflow-in-FSTART.patch b/0000-Fix-signed-integer-overflow-in-FSTART.patch deleted file mode 100644 index 8003da7..0000000 --- a/0000-Fix-signed-integer-overflow-in-FSTART.patch +++ /dev/null @@ -1,30 +0,0 @@ -From ed9facfbb0fa33e70ab95c21d49525f4f96224e2 Mon Sep 17 00:00:00 2001 -From: Jakub Wilk -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 -Signed-off-by: Andreas Bombe ---- - 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 - diff --git a/0001-Avoid-returning-deleted-directory-entries-as-labels.patch b/0001-Avoid-returning-deleted-directory-entries-as-labels.patch deleted file mode 100644 index 7528017..0000000 --- a/0001-Avoid-returning-deleted-directory-entries-as-labels.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 747c8f9522804a2fca43410acb700c4810a7c8a3 Mon Sep 17 00:00:00 2001 -From: Andreas Bombe -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 ---- - 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 - diff --git a/0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch b/0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch deleted file mode 100644 index b8ddf03..0000000 --- a/0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 87a8f29785bb605350821f1638a42e6cf3e49ce3 Mon Sep 17 00:00:00 2001 -From: Will Newton -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 ---- - 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 - diff --git a/0003-Remove-long-file-name-when-changing-short-file-name.patch b/0003-Remove-long-file-name-when-changing-short-file-name.patch deleted file mode 100644 index 3389929..0000000 --- a/0003-Remove-long-file-name-when-changing-short-file-name.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 4f953bb5d74e0eeda6cbee1e4871513edc7b912b Mon Sep 17 00:00:00 2001 -From: Andreas Bombe -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 - diff --git a/0004-Fix-gcc-sprintf-length-warnings.patch b/0004-Fix-gcc-sprintf-length-warnings.patch deleted file mode 100644 index 586c1be..0000000 --- a/0004-Fix-gcc-sprintf-length-warnings.patch +++ /dev/null @@ -1,61 +0,0 @@ -From fb0cc0df4ce3d349796ce4960c4e32d16532b203 Mon Sep 17 00:00:00 2001 -From: Andreas Bombe -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, ""); - sprintf(temp, " Size %u bytes, date %s", le32toh(file->dir_ent.size), tmp); - return temp; - } --- -1.8.3.1 - diff --git a/0005-fsck.fat-Fix-Year-2038-Bug.patch b/0005-fsck.fat-Fix-Year-2038-Bug.patch deleted file mode 100644 index 990cd71..0000000 --- a/0005-fsck.fat-Fix-Year-2038-Bug.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 607fbed2534cb80063395936384f4aef293812fd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Pali=20Roh=C3=A1r?= -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, ""); -- 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 - diff --git a/0006-mkfs.fat-Fix-parsing-of-block-number.patch b/0006-mkfs.fat-Fix-parsing-of-block-number.patch deleted file mode 100644 index fbba156..0000000 --- a/0006-mkfs.fat-Fix-parsing-of-block-number.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 086e13c72651439f39f678ffefb4f78b0c0fb758 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Pali=20Roh=C3=A1r?= -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 - diff --git a/0007-device_info-Fix-parsing-partition-number.patch b/0007-device_info-Fix-parsing-partition-number.patch deleted file mode 100644 index 70f4a52..0000000 --- a/0007-device_info-Fix-parsing-partition-number.patch +++ /dev/null @@ -1,48 +0,0 @@ -From af3e50dbe29e6ecf5ada3ff4dad12ac19f426d8d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Pali=20Roh=C3=A1r?= -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 - #include - #include -+#include -+#include - - #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 - diff --git a/dosfstools-4.1.tar.xz b/dosfstools-4.1.tar.xz deleted file mode 100644 index 125176b..0000000 Binary files a/dosfstools-4.1.tar.xz and /dev/null differ diff --git a/dosfstools-4.2.tar.gz b/dosfstools-4.2.tar.gz new file mode 100644 index 0000000..edcd9be Binary files /dev/null and b/dosfstools-4.2.tar.gz differ diff --git a/dosfstools.spec b/dosfstools.spec index ea3a4e7..4cef5a2 100644 --- a/dosfstools.spec +++ b/dosfstools.spec @@ -1,22 +1,13 @@ Name: dosfstools -Version: 4.1 -Release: 10 +Version: 4.2 +Release: 1 Summary: FAT file system userspace tools License: GPLv3+ 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 -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 - %description The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to create, check and label FAT family file systems. @@ -43,18 +34,26 @@ make check %make_install %files -%doc doc/* ChangeLog +%doc NEWS README doc/* ChangeLog %license COPYING %{_sbindir}/* +%exclude %{_docdir}/%{name}/COPYING %files help %{_mandir}/man8/* %changelog -* Fri Jul 30 2021 chenyanpanHW - 4.1-10 +* Wed Nov 17 2021 Wenchao Hao - 4.2-1 +- Update to dosfstools-4.2 + +* Fri Jul 30 2021 chenyanpanHW - 4.1-11 - DESC: delete -S git from %autosetup, and delete BuildRequires git +* Tue Feb 9 2021 Zhiqiang Liu - 4.1-10 +- backport patches to fix two memory leak problems, rename patch names, + and set release num to 9 for CI. + * Wed Nov 4 2020 lixiaokeng - 4.1-9 - add make check