summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch')
-rw-r--r--meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch b/meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch
new file mode 100644
index 0000000000..a8a49a80cd
--- /dev/null
+++ b/meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch
@@ -0,0 +1,34 @@
1From a13fc5a57ea7c6b1761bc204cb79d8ce4745f57a Mon Sep 17 00:00:00 2001
2From: songliang <YS.songliang@h3c.com>
3Date: Wed, 4 Jun 2025 15:58:53 +0800
4Subject: [PATCH] Modify "my_strncat" function
5
6The meaning of the "len" parameter in the my_strncat function is the size limit for copying characters from "from", not the size limit for "to" after copying.
7Also, the "#define safestrcat(to, from) my_strncat(to, from, sizeof(to) - strlen(to) - 1)" has already imposed a limit on max based on the size of "to".
8Modify the function to prevent truncation of content when too many bytes are passed to the my_strcat function.
9
10Upstream-Status: Submitted [https://github.com/linux-ras/sysfsutils/pull/30/commits/c2326946c0c2a4206c9b079a9fe25f7f9115295c]
11Signed-off-by: songliang <YS.songliang@h3c.com>
12Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
13---
14 lib/sysfs_utils.c | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/lib/sysfs_utils.c b/lib/sysfs_utils.c
18index 46e0849..c0176d1 100644
19--- a/lib/sysfs_utils.c
20+++ b/lib/sysfs_utils.c
21@@ -375,8 +375,8 @@ char *my_strncat(char *to, const char *from, size_t max)
22 {
23 size_t i = 0;
24
25- while (i < max && to[i] != '\0')
26+ while (to[i] != '\0')
27 i++;
28- my_strncpy(to+i, from, max-i);
29+ my_strncpy(to+i, from, max);
30 return to;
31 }
32--
332.34.1
34