From 0ec73be309bf01a5e2a00ca7f9aecd02ede65a67 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Wed, 7 Dec 2022 20:42:09 +0800 Subject: [PATCH] add sscanf adapation code for musl Signed-off-by: zhongtao --- 0020-add-sscanf-adapation-code-for-musl.patch | 31 +++++++++++++++++++ lxc.spec | 9 +++++- series.conf | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 0020-add-sscanf-adapation-code-for-musl.patch diff --git a/0020-add-sscanf-adapation-code-for-musl.patch b/0020-add-sscanf-adapation-code-for-musl.patch new file mode 100644 index 0000000..a9d5470 --- /dev/null +++ b/0020-add-sscanf-adapation-code-for-musl.patch @@ -0,0 +1,31 @@ +From 3cefa43ec2f5f0366c470290d48bdcd88690cf90 Mon Sep 17 00:00:00 2001 +From: isuladci +Date: Thu, 8 Dec 2022 09:48:29 +0800 +Subject: [PATCH] add sscanf adapation code for musl + +Signed-off-by: isuladci +--- + 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 + diff --git a/lxc.spec b/lxc.spec index 97a7beb..29229a8 100644 --- a/lxc.spec +++ b/lxc.spec @@ -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 - 4.0.3-2022102405 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: add sscanf adapation code for musl + * Fri Dec 02 2022 zhangxiaoyu - 4.0.3-2022102404 - Type:bugfix - ID:NA diff --git a/series.conf b/series.conf index 76b0638..104f149 100644 --- a/series.conf +++ b/series.conf @@ -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 -- Gitee