Compare commits

...

No commits in common. "imports/c9/exfatprogs-1.1.3-3.el9" and "c9-beta" have entirely different histories.

8 changed files with 169 additions and 99 deletions

View File

@ -1 +1 @@
6ff0ad86aceef6067af9d85bf7df181a86793c74 SOURCES/exfatprogs-1.1.3.tar.xz
e6d7751fe5c61340d3b9ce15f2109c6e5563f267 SOURCES/exfatprogs-1.2.2.tar.xz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/exfatprogs-1.1.3.tar.xz
SOURCES/exfatprogs-1.2.2.tar.xz

View File

@ -1,10 +0,0 @@
--- a/fsck/fsck.c 2021-11-17 10:13:55.729267514 +0100
+++ b/fsck/fsck.c 2022-05-10 12:19:36.397415101 +0200
@@ -796,6 +796,7 @@
if (exfat_read(exfat->blk_dev->dev_fd, boot_sect,
sizeof(*boot_sect), 0) != (ssize_t)sizeof(*boot_sect)) {
exfat_err("failed to read Main boot sector\n");
+ free(boot_sect);
return -EIO;
}

View File

@ -1,83 +0,0 @@
From 88a334ac2f98affcc526e861c2ed1b8bd2c34b3c Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Wed, 11 May 2022 23:20:43 +0200
Subject: [PATCH] exfatprogs: fix some minor code issues
* Add checking of function return value
* Fix potentially overflowing expression
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
fsck/de_iter.c | 9 ++++++---
lib/libexfat.c | 13 ++++++++++---
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/fsck/de_iter.c b/fsck/de_iter.c
index bc95c49..587b027 100644
--- a/fsck/de_iter.c
+++ b/fsck/de_iter.c
@@ -82,6 +82,9 @@ static int read_ahead_next_blocks(struct exfat_de_iter *iter,
offset >= iter->ra_begin_offset) {
ret = get_next_clus(exfat, iter->parent,
p_clus, &ra_p_clus);
+ if (ret)
+ return ret;
+
if (ra_p_clus == EXFAT_EOF_CLUSTER)
return -EIO;
@@ -172,10 +175,10 @@ static ssize_t read_block(struct exfat_de_iter *iter, unsigned int block)
ret = get_next_clus(exfat, iter->parent,
prev_desc->p_clus, &desc->p_clus);
desc->offset = 0;
- if (!ret && desc->p_clus == EXFAT_EOF_CLUSTER)
- return EOF;
- else if (ret)
+ if (ret)
return ret;
+ else if (desc->p_clus == EXFAT_EOF_CLUSTER)
+ return EOF;
}
}
diff --git a/lib/libexfat.c b/lib/libexfat.c
index 42e3fdc..ee48d3a 100644
--- a/lib/libexfat.c
+++ b/lib/libexfat.c
@@ -470,7 +470,12 @@ int exfat_set_volume_label(struct exfat_blk_dev *bd,
exfat_err("volume entry write failed: %d\n", errno);
return -1;
}
- fsync(bd->dev_fd);
+
+ if (fsync(bd->dev_fd) == -1) {
+ exfat_err("failed to sync volume entry: %d, %s\n", errno,
+ strerror(errno));
+ return -1;
+ }
exfat_info("new label: %s\n", label_input);
return 0;
@@ -479,7 +484,8 @@ int exfat_set_volume_label(struct exfat_blk_dev *bd,
int exfat_read_sector(struct exfat_blk_dev *bd, void *buf, unsigned int sec_off)
{
int ret;
- unsigned long long offset = sec_off * bd->sector_size;
+ unsigned long long offset =
+ (unsigned long long)sec_off * bd->sector_size;
ret = pread(bd->dev_fd, buf, bd->sector_size, offset);
if (ret < 0) {
@@ -493,7 +499,8 @@ int exfat_write_sector(struct exfat_blk_dev *bd, void *buf,
unsigned int sec_off)
{
int bytes;
- unsigned long long offset = sec_off * bd->sector_size;
+ unsigned long long offset =
+ (unsigned long long)sec_off * bd->sector_size;
bytes = pwrite(bd->dev_fd, buf, bd->sector_size, offset);
if (bytes != (int)bd->sector_size) {
--
2.35.3

View File

@ -0,0 +1,29 @@
From 79b5b71cc6a1dbc45eeb63f53a6b51aa924309c8 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Mon, 13 Nov 2023 08:13:27 +0100
Subject: [PATCH] exfat2img: fix Missing Initialization
exfatprogs-1.2.2/exfat2img/exfat2img.c:895: uninit_use: Using uninitialized value "ret".
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
exfat2img/exfat2img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/exfat2img/exfat2img.c b/exfat2img/exfat2img.c
index 3f83588..f1a4ef2 100644
--- a/exfat2img/exfat2img.c
+++ b/exfat2img/exfat2img.c
@@ -762,7 +762,7 @@ static ssize_t read_stream(int fd, void *buf, size_t len)
static int restore_from_stdin(struct exfat2img *ei)
{
- int in_fd, ret;
+ int in_fd, ret = 0;
unsigned char cc;
unsigned int clu, end_clu;
unsigned int cc_clu_count;
--
2.43.0

View File

@ -0,0 +1,71 @@
From cb641bd9b81179b7f039e6d0e64cd67e7fb4e11c Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Wed, 6 Dec 2023 22:01:04 +0100
Subject: [PATCH] exfatprogs: Fix issues found by OpenScanHub tool
Fix some issues found by red hat internal OpenScanHub tool.
exfatprogs-1.2.2/exfat2img/exfat2img.c:893: check_return: Calling
"fsync" without checking return value (as is done elsewhere
6 out of 7 times).
exfatprogs-1.2.2/fsck/fsck.c:1251:2: warning[deadcode.DeadStores]:
Value stored to 'err' is never read
exfatprogs-1.2.2/lib/libexfat.c:983: returned_null: "malloc" returns
"NULL" (checked 20 out of 23 times)
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
exfat2img/exfat2img.c | 5 ++++-
fsck/fsck.c | 1 -
lib/libexfat.c | 4 ++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/exfat2img/exfat2img.c b/exfat2img/exfat2img.c
index f1a4ef2..4774a56 100644
--- a/exfat2img/exfat2img.c
+++ b/exfat2img/exfat2img.c
@@ -890,7 +890,10 @@ static int restore_from_stdin(struct exfat2img *ei)
}
}
out:
- fsync(ei->out_fd);
+ if (fsync(ei->out_fd)) {
+ exfat_err("failed to fsync: %d\n", errno);
+ ret = -EIO;
+ }
exfat_free_buffer(ei->dump_bdesc, 2);
return ret;
}
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 77272aa..a5517d2 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1248,7 +1248,6 @@ static int exfat_root_dir_check(struct exfat *exfat)
err = exfat_read_volume_label(exfat);
if (err && err != EOF)
exfat_err("failed to read volume label\n");
- err = 0;
err = read_bitmap(exfat);
if (err) {
diff --git a/lib/libexfat.c b/lib/libexfat.c
index d7b8344..6ae5742 100644
--- a/lib/libexfat.c
+++ b/lib/libexfat.c
@@ -981,6 +981,10 @@ int read_boot_sect(struct exfat_blk_dev *bdev, struct pbr **bs)
unsigned int sect_size, clu_size;
pbr = malloc(sizeof(struct pbr));
+ if (!pbr) {
+ exfat_err("failed to allocate memory\n");
+ return -ENOMEM;
+ }
if (exfat_read(bdev->dev_fd, pbr, sizeof(*pbr), 0) !=
(ssize_t)sizeof(*pbr)) {
--
2.43.0

View File

@ -0,0 +1,43 @@
From 8e4f2e671a154549d07ec45cb3c9cfe31b27b27f Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Mon, 13 Nov 2023 08:37:06 +0100
Subject: [PATCH] tune: label: fix USE_AFTER_FREE
double_free: Calling free frees pointer bs which has already been freed.
if exfat_alloc_exfat fails it already frees exfat->bs via exfat_free_exfat
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
label/label.c | 1 -
tune/tune.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/label/label.c b/label/label.c
index 8cd5748..b110670 100644
--- a/label/label.c
+++ b/label/label.c
@@ -105,7 +105,6 @@ int main(int argc, char *argv[])
exfat = exfat_alloc_exfat(&bd, bs);
if (!exfat) {
- free(bs);
ret = -ENOMEM;
goto close_fd_out;
}
diff --git a/tune/tune.c b/tune/tune.c
index f883556..fdb8c94 100644
--- a/tune/tune.c
+++ b/tune/tune.c
@@ -129,7 +129,6 @@ int main(int argc, char *argv[])
exfat = exfat_alloc_exfat(&bd, bs);
if (!exfat) {
- free(bs);
ret = -ENOMEM;
goto close_fd_out;
}
--
2.43.0

View File

@ -1,13 +1,14 @@
Name: exfatprogs
Version: 1.1.3
Release: 3%{?dist}
Version: 1.2.2
Release: 2%{?dist}
Summary: Userspace utilities for exFAT filesystems
License: GPLv2
URL: https://github.com/%{name}/%{name}
Source0: %{url}/releases/download/%{version}/%{name}-%{version}.tar.xz
Patch0: 0001-fsck-fix-memory-leak.patch
Patch1: 0002.patch
Patch0: for-next-1.2.2-exfat2img-fix-Missing-Initialization.patch
Patch1: for-next-1.2.2-exfatprogs-Fix-issues-found-by-OpenScanHub-tool.patch
Patch2: for-next-1.2.2-tune-label-fix-USE_AFTER_FREE.patch
BuildRequires: autoconf
BuildRequires: automake
@ -36,16 +37,35 @@ autoreconf -vif
%doc README.md
%{_sbindir}/dump.exfat
%{_sbindir}/exfatlabel
%{_sbindir}/exfat2img
%{_sbindir}/fsck.exfat
%{_sbindir}/mkfs.exfat
%{_sbindir}/tune.exfat
%{_mandir}/man8/dump.exfat.*
%{_mandir}/man8/exfatlabel.*
%{_mandir}/man8/exfat2img.*
%{_mandir}/man8/fsck.exfat.*
%{_mandir}/man8/mkfs.exfat.*
%{_mandir}/man8/tune.exfat.*
%changelog
* Fri Dec 08 2023 Pavel Reichl <preichl@redhat.com> - 1.2.2-2
- Backport fixes for issues found by OpenScanHub
- Related: RHEL-7945
* Mon Nov 06 2023 Pavel Reichl <preichl@redhat.com> - 1.2.2-1
- Rebase to upstream v1.2.2
- Related: RHEL-15865
- Related: RHEL-14995
* Mon Mar 13 2023 Pavel Reichl <preichl@redhat.com> - 1.2.0-2
- Fix wrong BZ number in git log
Related: rhbz#2173273
* Mon Mar 06 2023 Pavel Reichl <preichl@redhat.com> - 1.2.0-1
- Rebase
Related: rhbz#2173273
* Tue May 24 2022 Pavel Reichl <preichl@redhat.com> - 1.1.3-3.test
- Fix some covscan issues