From c79a1f156c6ba3b7dc03fe7e321aa8aad5733df5 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Thu, 8 Dec 2022 02:30:58 +0000 Subject: [PATCH] add sscanf adapation code for musl Signed-off-by: zhongtao --- 0055-add-sscanf-adapation-code-for-musl.patch | 31 +++++++++++++++++++ lxc.spec | 9 +++++- series.conf | 4 ++- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 0055-add-sscanf-adapation-code-for-musl.patch diff --git a/0055-add-sscanf-adapation-code-for-musl.patch b/0055-add-sscanf-adapation-code-for-musl.patch new file mode 100644 index 0000000..613dfbf --- /dev/null +++ b/0055-add-sscanf-adapation-code-for-musl.patch @@ -0,0 +1,31 @@ +From 04399ce74d89f7260474e915a978d31d62367889 Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Wed, 4 Jan 2023 13:17:34 +0800 +Subject: [PATCH] add sscanf adapation code for musl + +Signed-off-by: zhongtao +--- + src/lxc/utils.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/lxc/utils.c b/src/lxc/utils.c +index ed66935..3838f69 100644 +--- a/src/lxc/utils.c ++++ b/src/lxc/utils.c +@@ -2134,7 +2134,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 b00ad29..9ef5500 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2022102406 +%global _release 2022102407 Name: lxc Version: 4.0.3 @@ -62,6 +62,7 @@ Patch0051: 0051-add-macro-to-adapt-musl-libc.patch Patch0052: 0052-add-lxc-attach-add-gids-option.patch Patch0053: 0053-change-the-suffi-parameter-in-lxc-attach-help-output.patch Patch0054: 0054-rollback-strprint-code-modified.patch +Patch0055: 0055-add-sscanf-adapation-code-for-musl.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -242,6 +243,12 @@ make check %endif %changelog +* Wed Jan 04 2023 zhongtao - 4.0.3-2022102407 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: add sscanf adapation code for musl + * Mon Dec 26 2022 zhangxiaoyu - 4.0.3-2022102406 - Type:bugfix - ID:NA diff --git a/series.conf b/series.conf index 3312f78..76f5386 100644 --- a/series.conf +++ b/series.conf @@ -50,4 +50,6 @@ 0050-lxc-Add-sw64-architecture.patch 0051-add-macro-to-adapt-musl-libc.patch 0052-add-lxc-attach-add-gids-option.patch -0053-change-the-suffi-parameter-in-lxc-attach-help-output.patch \ No newline at end of file +0053-change-the-suffi-parameter-in-lxc-attach-help-output.patch +0054-rollback-strprint-code-modified.patch +0055-add-sscanf-adapation-code-for-musl.patch -- Gitee