From 04cc5feaa810f09e4e088d8bcc33b51cf8e9dee9 Mon Sep 17 00:00:00 2001 From: ship_harbour Date: Fri, 17 Mar 2023 15:35:25 +0800 Subject: [PATCH] coreutils:add backport-fts-fail-gracefully-when-out-of-memory.patch for malloc failed --- ...s-fail-gracefully-when-out-of-memory.patch | 50 +++++++++++++++++++ coreutils.spec | 6 ++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 backport-fts-fail-gracefully-when-out-of-memory.patch diff --git a/backport-fts-fail-gracefully-when-out-of-memory.patch b/backport-fts-fail-gracefully-when-out-of-memory.patch new file mode 100644 index 0000000..a28f48e --- /dev/null +++ b/backport-fts-fail-gracefully-when-out-of-memory.patch @@ -0,0 +1,50 @@ +From f17d397771164c1b0f77fea8fb0abdc99cf4a3e1 Mon Sep 17 00:00:00 2001 +From: ChuanGang Jiang +Date: Mon, 27 Feb 2023 11:46:12 +0000 +Subject: [PATCH] fts: fail gracefully when out of memory + +* lib/fts.c (fts_read): Set errno==ENOMEM and return NULL +when setup_dir() fails, rather than hitting an assertion later. + +Refernece:https://github.com/coreutils/gnulib/commit/f17d397771164c1b0f77fea8fb0abdc99cf4a3e1 +Conflict:ChangeLog context adaptation + +--- + ChangeLog | 6 ++++++ + lib/fts.c | 6 +++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index 1785234..43b0afa 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,9 @@ ++2023-02-27 ChuanGang Jiang ++ ++ fts: fail gracefully when out of memory ++ * lib/fts.c (fts_read): Set errno==ENOMEM and return NULL ++ when setup_dir() fails, rather than hitting an assertion later. ++ + 2022-12-06 Paul Eggert + + fts: fix race + mishandling of fstatat failure +diff --git a/lib/fts.c b/lib/fts.c +index 78584b2902..794a4f75d7 100644 +--- a/lib/fts.c ++++ b/lib/fts.c +@@ -979,7 +979,11 @@ next: tmp = p; + } + free_dir(sp); + fts_load(sp, p); +- setup_dir(sp); ++ if (! setup_dir(sp)) { ++ free_dir(sp); ++ __set_errno (ENOMEM); ++ return (NULL); ++ } + goto check_for_dir; + } + +-- +2.27.0 + diff --git a/coreutils.spec b/coreutils.spec index ac7650c..efd968c 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.0 -Release: 8 +Release: 9 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -36,6 +36,7 @@ Patch20: backport-fts-fix-race-mishandling-of-fstatat-failure.patch Patch21: backport-stty-fix-off-by-one-column-wrapping-on-output.patch Patch22: backport-copy-copy_file_range-handle-ENOENT-for-CIFS.patch Patch23: backport-tail-fix-support-for-F-with-non-seekable-files.patch +Patch24: backport-fts-fail-gracefully-when-out-of-memory.patch Patch9000: openEuler-coreutils-df-direct.patch %ifarch sw_64 @@ -163,6 +164,9 @@ fi %{_mandir}/man*/* %changelog +* Fri Mar 17 2023 jiangchuangang - 9.0-9 +- add backport-fts-fail-gracefully-when-out-of-memory.patch for malloc failed + * Fri Mar 17 2023 jiangchuangang - 9.0-8 - sync patches from community - add backport-comm-fix-NUL-output-delimiter-with-total.patch -- Gitee