Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
304294f441
!30 fix asnprintf implementation
From: @wuyifeng12 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-08-01 02:35:41 +00:00
EulerOSWander
a08264d348 Fix vasprintf implementation 2024-07-31 16:53:30 +08:00
openeuler-ci-bot
09e7b7c3c5
!23 Synchronize Version
From: @hifi521 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-11-07 02:18:37 +00:00
zhanchengbin
95ace15d4f Synchronize Version
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
2022-11-04 14:50:44 +08:00
openeuler-ci-bot
0be1fdfe68 !18 Update to dosfstools-4.2
From: @wenchao-hao
Reviewed-by: @liuzhiqiang26
Signed-off-by: @liuzhiqiang26
2021-11-23 11:00:37 +00:00
Wenchao Hao
943efa80b4 Update to dosfstools-4.2
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
2021-11-17 14:41:02 +08:00
openeuler-ci-bot
2216938f65 !13 Synchronize Version
From: @hifi521
Reviewed-by: @wubo009
Signed-off-by: @wubo009
2021-09-28 08:42:18 +00:00
Zhiqiang Liu
975ac1583a dosfstools: backport patches to fix two memory leak problems
- backport patches to fix two memory leak problems.
- rename patches
- set release num to 9 for ci.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>

Conflicts:
	dosfstools.spec
2021-09-28 16:32:52 +08:00
openeuler-ci-bot
b0a422e416 !8 dosfstools delete -S git from %autosetup, and delete BuildRequires git
From: @chenyanpanHW
Reviewed-by: @liuzhiqiang26
Signed-off-by: @liuzhiqiang26
2021-07-31 07:18:54 +00:00
chenyanpanHW
de3de46754
delete -S git from %autosetup, and delete BuildRequires git 2021-07-30 22:35:35 +08:00
12 changed files with 51 additions and 433 deletions

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,27 @@
From 5564db86e9c082ef6d0f26cb23c92a0bcdc2b14a Mon Sep 17 00:00:00 2001
From: wuyifeng <wuyifeng10@huawei.com>
Date: Wed, 31 Jul 2024 15:17:04 +0800
Subject: [PATCH] Fix vasprintf implementation
A va_copy call must be followed by a va_end call.
---
src/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/common.c b/src/common.c
index 6a2e396..c33cbea 100644
--- a/src/common.c
+++ b/src/common.c
@@ -123,8 +123,8 @@ static int vasprintf(char **strp, const char *fmt, va_list va)
va_list vacopy;
va_copy(vacopy, va);
-
length = vsnprintf(NULL, 0, fmt, vacopy);
+ va_end(vacopy);
if (length < 0)
return length;
--
2.33.0

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

Binary file not shown.

BIN
dosfstools-4.2.tar.gz Normal file

Binary file not shown.

View File

@ -1,21 +1,14 @@
Name: dosfstools
Version: 4.1
Release: 9
Version: 4.2
Release: 3
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 git autoconf automake
Patch1: 0001-Fix-vasprintf-implementation.patch
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
BuildRequires: gcc autoconf automake
%description
The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to
@ -30,7 +23,7 @@ Requires: man
This package includes man pages for dosfstools.
%prep
%autosetup -n %{name}-%{version} -p1 -S git
%autosetup -n %{name}-%{version} -p1
%build
%configure --enable-compat-symlinks
@ -43,15 +36,32 @@ 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
* Wed Jul 31 2024 wuyifeng <wuyifeng10@huawei.com> - 4.2-3
- Fix vasprintf implementation
* Fri Nov 4 2022 zhanchengbin <zhanchengbin1@huawei.com> - 4.2-2
- Synchronize Version
* 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
- DESC: delete -S git from %autosetup, and delete BuildRequires git
* Tue Feb 9 2021 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 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 <lixiaokeng@huawei.com> - 4.1-9
- add make check