diff options
author | Yi Zhao <yi.zhao@eng.windriver.com> | 2025-07-20 22:03:49 +0800 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2025-07-27 14:35:10 -0400 |
commit | dca497d728792e3cb655c78455c2d649af312ce8 (patch) | |
tree | 898144cefb24260ed4e3d89c234c4914f0739c65 | |
parent | 78447a67fc8495d485b327d984147d9fd519d8b0 (diff) | |
download | meta-openembedded-walnascar-next.tar.gz |
][PATCH] ufs-utils: fix crash for ufs-utils list_bsgwalnascar-next
The full_path buffer in find_bsg_device function consists of:
path + '/' + files->d_name + '\0'
So the buffer size should be: strlen(path) + strlen(files->d_name) + 2,
not: strlen(path) + strlen(files->d_name) + 1.
Backport a patch to fix crash when running 32-bit binary on 64-bit
system:
$ ufs-utils list_bsg
malloc(): invalid next size (unsorted)
Aborted (core dumped)
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-filesystems/recipes-utils/ufs-utils/files/0001-ufs_cmds-fix-full_path-buffer-size-in-find_bsg_devic.patch | 39 | ||||
-rw-r--r-- | meta-filesystems/recipes-utils/ufs-utils/ufs-utils_4.13.5.bb | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/meta-filesystems/recipes-utils/ufs-utils/files/0001-ufs_cmds-fix-full_path-buffer-size-in-find_bsg_devic.patch b/meta-filesystems/recipes-utils/ufs-utils/files/0001-ufs_cmds-fix-full_path-buffer-size-in-find_bsg_devic.patch new file mode 100644 index 0000000000..7ae858a65e --- /dev/null +++ b/meta-filesystems/recipes-utils/ufs-utils/files/0001-ufs_cmds-fix-full_path-buffer-size-in-find_bsg_devic.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From 989dcd297223d6896c5892532d14984326fa093d Mon Sep 17 00:00:00 2001 | ||
2 | From: Yi Zhao <yi.zhao@windriver.com> | ||
3 | Date: Fri, 18 Jul 2025 16:52:57 +0800 | ||
4 | Subject: [PATCH] ufs_cmds: fix full_path buffer size in find_bsg_device | ||
5 | |||
6 | The full_path buffer consists of: path + '/' + files->d_name + '\0' | ||
7 | So the buffer size should be: strlen(path) + strlen(files->d_name) + 2 | ||
8 | |||
9 | Fix crash when running 32-bit binary on 64-bit system: | ||
10 | $ ufs-utils list_bsg | ||
11 | malloc(): invalid next size (unsorted) | ||
12 | Aborted (core dumped) | ||
13 | |||
14 | Fix #58 | ||
15 | |||
16 | Upstream-Status: Backport | ||
17 | [https://github.com/SanDisk-Open-Source/ufs-utils/commit/989dcd297223d6896c5892532d14984326fa093d] | ||
18 | |||
19 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
20 | --- | ||
21 | ufs_cmds.c | 2 +- | ||
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
23 | |||
24 | diff --git a/ufs_cmds.c b/ufs_cmds.c | ||
25 | index ddb037c..a6faa27 100644 | ||
26 | --- a/ufs_cmds.c | ||
27 | +++ b/ufs_cmds.c | ||
28 | @@ -1520,7 +1520,7 @@ static int find_bsg_device(char* path, int *counter) { | ||
29 | if ((strcmp(files->d_name, ".") != 0) && | ||
30 | (strcmp(files->d_name, "..") != 0)) { | ||
31 | char *full_path = (char *)malloc(strlen(path) + | ||
32 | - strlen(files->d_name) + 1); | ||
33 | + strlen(files->d_name) + 2); | ||
34 | sprintf(full_path, "%s/%s", | ||
35 | path, files->d_name); | ||
36 | rc = find_bsg_device(full_path, counter); | ||
37 | -- | ||
38 | 2.34.1 | ||
39 | |||
diff --git a/meta-filesystems/recipes-utils/ufs-utils/ufs-utils_4.13.5.bb b/meta-filesystems/recipes-utils/ufs-utils/ufs-utils_4.13.5.bb index 7126684e61..aac710cfca 100644 --- a/meta-filesystems/recipes-utils/ufs-utils/ufs-utils_4.13.5.bb +++ b/meta-filesystems/recipes-utils/ufs-utils/ufs-utils_4.13.5.bb | |||
@@ -7,6 +7,7 @@ BRANCH ?= "dev" | |||
7 | SRCREV = "18c0a8454ca1cf8969170049f8c628d88627beec" | 7 | SRCREV = "18c0a8454ca1cf8969170049f8c628d88627beec" |
8 | 8 | ||
9 | SRC_URI = "git://github.com/westerndigitalcorporation/ufs-utils.git;protocol=https;branch=${BRANCH} \ | 9 | SRC_URI = "git://github.com/westerndigitalcorporation/ufs-utils.git;protocol=https;branch=${BRANCH} \ |
10 | file://0001-ufs_cmds-fix-full_path-buffer-size-in-find_bsg_devic.patch \ | ||
10 | " | 11 | " |
11 | 12 | ||
12 | UPSTREAM_CHECK_COMMITS = "1" | 13 | UPSTREAM_CHECK_COMMITS = "1" |