!381 add sscanf adapation code for musl

* add sscanf adapation code for musl
This commit is contained in:
zhongtao 2022-12-08 02:30:58 +00:00 committed by haozi007
parent 9d5ef28c6d
commit a4d3abf3d9
3 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From 3cefa43ec2f5f0366c470290d48bdcd88690cf90 Mon Sep 17 00:00:00 2001
From: isuladci <isulad@ci.com>
Date: Thu, 8 Dec 2022 09:48:29 +0800
Subject: [PATCH] add sscanf adapation code for musl
Signed-off-by: isuladci <isulad@ci.com>
---
src/lxc/isulad_utils.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/lxc/isulad_utils.c b/src/lxc/isulad_utils.c
index 067e1c9..ee39302 100644
--- a/src/lxc/isulad_utils.c
+++ b/src/lxc/isulad_utils.c
@@ -173,7 +173,13 @@ static proc_t *lxc_stat2proc(const char *S)
(void)memset(P, 0x00, sizeof(proc_t));
/* parse these two strings separately, skipping the leading "(". */
+ /* https://www.openwall.com/lists/musl/2013/11/15/5: musl's sscanf("%15c",cmd)
+ requires exactly 15 characters; anything shorter is a matching failure. */
+#ifdef __MUSL__
+ num = sscanf(S, "%d (%15s", &P->pid, P->cmd); /* comm[16] in kernel */
+#else
num = sscanf(S, "%d (%15c", &P->pid, P->cmd); /* comm[16] in kernel */
+#endif
if (num != 2) {
ERROR("Call sscanf error: %s", errno ? strerror(errno) : "");
free(P);
--
2.25.1

View File

@ -1,4 +1,4 @@
%global _release 2022102404
%global _release 2022102405
Name: lxc
Version: 4.0.3
@ -27,6 +27,7 @@ Patch0016: 0016-skip-kill-cgroup-processes-if-no-hierarchies.patch
Patch0017: 0017-lxc-Add-sw64-architecture.patch
Patch0018: 0018-add-macro-to-adapt-musl-libc.patch
Patch0019: 0019-add-lxc-attach-add-gids-option.patch
Patch0020: 0020-add-sscanf-adapation-code-for-musl.patch
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
BuildRequires: pkgconfig(libseccomp)
@ -207,6 +208,12 @@ make check
%endif
%changelog
* Thu Dec 08 2022 zhongtao<zhongtao17@huawei.com> - 4.0.3-2022102405
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: add sscanf adapation code for musl
* Fri Dec 02 2022 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 4.0.3-2022102404
- Type:bugfix
- ID:NA

View File

@ -16,3 +16,4 @@
0017-lxc-Add-sw64-architecture.patch
0018-add-macro-to-adapt-musl-libc.patch
0019-add-lxc-attach-add-gids-option.patch
0020-add-sscanf-adapation-code-for-musl.patch