Compare commits
No commits in common. "63d29118c4caccba02dd38e11fe488ecdf4a9557" and "b1a0e5175da467ef8fbcb6a6bdcd3553fc1dd866" have entirely different histories.
63d29118c4
...
b1a0e5175d
@ -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
|
|
||||||
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
From b71c7c400276cc48acc257c294e01825773100dc Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
|
||||||
Date: Sat, 11 Aug 2018 20:34:08 +0200
|
|
||||||
Subject: [PATCH] mkfs.fat: Fix calculation of FAT32 cluster size on non 512
|
|
||||||
bytes sector disks
|
|
||||||
|
|
||||||
Previous FAT32 calculation worked correctly only for disks with 512 byte
|
|
||||||
sectors. New calculation formula is generalized variant of previous one,
|
|
||||||
but to be sector size independent.
|
|
||||||
---
|
|
||||||
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 ff89013..f7d8607 100644
|
|
||||||
--- a/src/mkfs.fat.c
|
|
||||||
+++ b/src/mkfs.fat.c
|
|
||||||
@@ -588,13 +588,13 @@ static void establish_params(struct device_info *info)
|
|
||||||
* fs size <= 16G: 8k clusters
|
|
||||||
* fs size <= 32G: 16k clusters
|
|
||||||
* fs size > 32G: 32k clusters
|
|
||||||
- *
|
|
||||||
- * This only works correctly for 512 byte sectors!
|
|
||||||
*/
|
|
||||||
- uint32_t sz_mb = info->size / (1024 * 1024);
|
|
||||||
- cluster_size =
|
|
||||||
- sz_mb > 32 * 1024 ? 64 : sz_mb > 16 * 1024 ? 32 : sz_mb >
|
|
||||||
- 8 * 1024 ? 16 : sz_mb > 260 ? 8 : 1;
|
|
||||||
+ unsigned long long int sectors = info->size / sector_size;
|
|
||||||
+ cluster_size = sectors > 32*1024*1024*2 ? 64 :
|
|
||||||
+ sectors > 16*1024*1024*2 ? 32 :
|
|
||||||
+ sectors > 8*1024*1024*2 ? 16 :
|
|
||||||
+ sectors > 260*1024*2 ? 8 : 1;
|
|
||||||
+
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info->geom_heads > 0) {
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,24 +1,21 @@
|
|||||||
Name: dosfstools
|
Name: dosfstools
|
||||||
Version: 4.1
|
Version: 4.1
|
||||||
Release: 13
|
Release: 7
|
||||||
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.xz
|
||||||
|
|
||||||
BuildRequires: gcc autoconf automake systemd-devel
|
BuildRequires: gcc git autoconf automake
|
||||||
|
|
||||||
Patch0: 0000-Fix-signed-integer-overflow-in-FSTART.patch
|
Patch6000: 6000-Fix-signed-integer-overflow-in-FSTART.patch
|
||||||
Patch1: 0001-Avoid-returning-deleted-directory-entries-as-labels.patch
|
Patch6001: 6001-Avoid-returning-deleted-directory-entries-as-labels.patch
|
||||||
Patch2: 0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch
|
Patch6002: 6002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch
|
||||||
Patch3: 0003-Remove-long-file-name-when-changing-short-file-name.patch
|
Patch6003: 6003-Remove-long-file-name-when-changing-short-file-name.patch
|
||||||
Patch4: 0004-Fix-gcc-sprintf-length-warnings.patch
|
Patch6004: 6004-Fix-gcc-sprintf-length-warnings.patch
|
||||||
Patch5: 0005-fsck.fat-Fix-Year-2038-Bug.patch
|
Patch6005: 6005-fsck.fat-Fix-Year-2038-Bug.patch
|
||||||
Patch6: 0006-mkfs.fat-Fix-parsing-of-block-number.patch
|
Patch6006: 6006-mkfs.fat-Fix-parsing-of-block-number.patch
|
||||||
Patch7: 0007-device_info-Fix-parsing-partition-number.patch
|
Patch6007: 6007-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
|
|
||||||
Patch10: 0010-mkfs.fat-Fix-calculation-of-FAT32-cluster-size-on-no.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
|
||||||
@ -33,14 +30,11 @@ Requires: man
|
|||||||
This package includes man pages for dosfstools.
|
This package includes man pages for dosfstools.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{name}-%{version} -p1
|
%autosetup -n %{name}-%{version} -p1 -S git
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --enable-compat-symlinks
|
%configure --enable-compat-symlinks
|
||||||
%make_build CFLAGS="%{optflags} -D HAVE_UDEV -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing"
|
%make_build CFLAGS="%{optflags} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing"
|
||||||
|
|
||||||
%check
|
|
||||||
make check
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%make_install
|
%make_install
|
||||||
@ -55,25 +49,6 @@ make check
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Nov 30 2023 wuguanghao <wuguanghao3@huawei.com> - 4.1-13
|
|
||||||
- mkfs.fat: Fix calculation of FAT32 cluster size on no 512 bytes sector disks
|
|
||||||
|
|
||||||
* Tue Jul 5 2022 zhanchengbin <zhanchengbin1@huawei.com> - 4.1-12
|
|
||||||
- fix execution successd when format a disk with partitions.
|
|
||||||
|
|
||||||
* 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
|
|
||||||
|
|
||||||
* Wed Jul 1 2020 Wu Bo <wubo009@163.com> - 4.1-8
|
|
||||||
- rebuild package
|
|
||||||
|
|
||||||
* Tue Aug 20 2019 luoshijie <luoshijie1@huawei.com> - 4.1-7
|
* Tue Aug 20 2019 luoshijie <luoshijie1@huawei.com> - 4.1-7
|
||||||
- Type:enhancement
|
- Type:enhancement
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user