sync community patches
This commit is contained in:
parent
a6183a9f7a
commit
9d29e8046c
98
mkfs.bfs-fix-memory-leaks-and-weak-code.patch
Normal file
98
mkfs.bfs-fix-memory-leaks-and-weak-code.patch
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
From 2c6ce1240f118a2d00ad93060da409c3995b7f67 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Tue, 1 Apr 2025 15:54:07 +0200
|
||||||
|
Subject: [PATCH] mkfs.bfs: fix memory leaks and weak code
|
||||||
|
|
||||||
|
---
|
||||||
|
disk-utils/mkfs.bfs.c | 34 ++++++++++++++++++++++------------
|
||||||
|
1 file changed, 22 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
|
||||||
|
index 54d261b..71e8b6b 100644
|
||||||
|
--- a/disk-utils/mkfs.bfs.c
|
||||||
|
+++ b/disk-utils/mkfs.bfs.c
|
||||||
|
@@ -93,19 +93,23 @@ static void __attribute__((__noreturn__)) usage(void)
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- char *device, *volume, *fsname;
|
||||||
|
+ char *device, *volume = NULL, *fsname = NULL;
|
||||||
|
long inodes;
|
||||||
|
unsigned long long total_blocks, ino_bytes, ino_blocks, data_blocks;
|
||||||
|
unsigned long long user_specified_total_blocks = 0;
|
||||||
|
int verbose = 0;
|
||||||
|
int fd;
|
||||||
|
uint32_t first_block;
|
||||||
|
- struct bfssb sb;
|
||||||
|
struct bfsi ri;
|
||||||
|
struct bfsde de;
|
||||||
|
struct stat statbuf;
|
||||||
|
time_t now;
|
||||||
|
- int c, i, len;
|
||||||
|
+ int c, i;
|
||||||
|
+ size_t len;
|
||||||
|
+ struct bfssb sb = {
|
||||||
|
+ .s_fsname = "\x20\x20\x20\x20\x20\x20",
|
||||||
|
+ .s_volume = "\x20\x20\x20\x20\x20\x20"
|
||||||
|
+ };
|
||||||
|
|
||||||
|
enum { VERSION_OPTION = CHAR_MAX + 1 };
|
||||||
|
static const struct option longopts[] = {
|
||||||
|
@@ -130,7 +134,6 @@ int main(int argc, char **argv)
|
||||||
|
if (argc == 2 && !strcmp(argv[1], "-V"))
|
||||||
|
print_version(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
- volume = fsname = " "; /* is there a default? */
|
||||||
|
inodes = 0;
|
||||||
|
|
||||||
|
while ((c = getopt_long(argc, argv, "N:V:F:vhcl", longopts, NULL)) != -1) {
|
||||||
|
@@ -140,17 +143,21 @@ int main(int argc, char **argv)
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'V':
|
||||||
|
+ if (volume)
|
||||||
|
+ errx(EXIT_FAILURE, _("more than one volume"));
|
||||||
|
len = strlen(optarg);
|
||||||
|
- if (len <= 0 || len > 6)
|
||||||
|
+ if (!len || len > sizeof(sb.s_volume))
|
||||||
|
errx(EXIT_FAILURE, _("volume name too long"));
|
||||||
|
- volume = xstrdup(optarg);
|
||||||
|
+ volume = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'F':
|
||||||
|
+ if (fsname)
|
||||||
|
+ errx(EXIT_FAILURE, _("more than one fsname"));
|
||||||
|
len = strlen(optarg);
|
||||||
|
- if (len <= 0 || len > 6)
|
||||||
|
+ if (!len || len > sizeof(sb.s_fsname))
|
||||||
|
errx(EXIT_FAILURE, _("fsname name too long"));
|
||||||
|
- fsname = xstrdup(optarg);
|
||||||
|
+ fsname = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
@@ -233,13 +240,16 @@ int main(int argc, char **argv)
|
||||||
|
sb.s_start = cpu_to_le32(ino_bytes + sizeof(struct bfssb));
|
||||||
|
sb.s_end = cpu_to_le32(total_blocks * BFS_BLOCKSIZE - 1);
|
||||||
|
sb.s_from = sb.s_to = sb.s_backup_from = sb.s_backup_to = -1;
|
||||||
|
- memcpy(sb.s_fsname, fsname, 6);
|
||||||
|
- memcpy(sb.s_volume, volume, 6);
|
||||||
|
+
|
||||||
|
+ if (fsname)
|
||||||
|
+ str2memcpy(sb.s_fsname, fsname, sizeof(sb.s_fsname));
|
||||||
|
+ if (volume)
|
||||||
|
+ str2memcpy(sb.s_volume, volume, sizeof(sb.s_volume));
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
fprintf(stderr, _("Device: %s\n"), device);
|
||||||
|
- fprintf(stderr, _("Volume: <%-6s>\n"), volume);
|
||||||
|
- fprintf(stderr, _("FSname: <%-6s>\n"), fsname);
|
||||||
|
+ fprintf(stderr, _("Volume: <%.6s>\n"), sb.s_volume);
|
||||||
|
+ fprintf(stderr, _("FSname: <%.6s>\n"), sb.s_fsname);
|
||||||
|
fprintf(stderr, _("BlockSize: %d\n"), BFS_BLOCKSIZE);
|
||||||
|
if (ino_blocks == 1)
|
||||||
|
fprintf(stderr, _("Inodes: %ld (in 1 block)\n"),
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.37.2
|
Version: 2.37.2
|
||||||
Release: 40
|
Release: 41
|
||||||
Summary: A random collection of Linux utilities
|
Summary: A random collection of Linux utilities
|
||||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
||||||
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
||||||
@ -177,6 +177,7 @@ Patch9002: util-linux-Add-sw64-architecture.patch
|
|||||||
%endif
|
%endif
|
||||||
Patch9003: backport-uuidd-fix-open-lock-state-issue.patch
|
Patch9003: backport-uuidd-fix-open-lock-state-issue.patch
|
||||||
Patch9004: sfdisk-fix-crash-casued-by-out-of-bounds-access.patch
|
Patch9004: sfdisk-fix-crash-casued-by-out-of-bounds-access.patch
|
||||||
|
Patch9005: mkfs.bfs-fix-memory-leaks-and-weak-code.patch
|
||||||
|
|
||||||
BuildRequires: audit-libs-devel >= 1.0.6 gettext-devel libselinux-devel ncurses-devel pam-devel zlib-devel popt-devel
|
BuildRequires: audit-libs-devel >= 1.0.6 gettext-devel libselinux-devel ncurses-devel pam-devel zlib-devel popt-devel
|
||||||
BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc autoconf automake
|
BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc autoconf automake
|
||||||
@ -547,6 +548,13 @@ fi
|
|||||||
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 11 2025 zhangting <dev03303@linx-info.com> - 2.37.2-41
|
||||||
|
- Type:bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC: fix an issue that mkfs.bfs fix memory leak
|
||||||
|
mkfs.bfs-fix-memory-leaks-and-weak-code.patch
|
||||||
|
|
||||||
* Mon Mar 03 2025 zhangyao <zhangyao108@huawei.com> - 2.37.2-40
|
* Mon Mar 03 2025 zhangyao <zhangyao108@huawei.com> - 2.37.2-40
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user