From c56b0fc1fa0ef7c488a2619d839b99aea373dfc6 Mon Sep 17 00:00:00 2001 From: zhangrui Date: Fri, 21 Apr 2023 14:25:54 +0800 Subject: [PATCH] add check after malloc allocation (cherry picked from commit afcdfae3a0254d5701de5b3f0e642e21f822fd40) --- ...rt-Add-check-after-malloc-allocation.patch | 31 +++++++++++++++++++ libdnf.spec | 6 +++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 backport-Add-check-after-malloc-allocation.patch diff --git a/backport-Add-check-after-malloc-allocation.patch b/backport-Add-check-after-malloc-allocation.patch new file mode 100644 index 0000000..c5b4cb2 --- /dev/null +++ b/backport-Add-check-after-malloc-allocation.patch @@ -0,0 +1,31 @@ +From 466bd9dd8b8836af34f29976a5b0b83950bbe8ed Mon Sep 17 00:00:00 2001 +From: Li kunyu +Date: Mon, 19 Dec 2022 15:20:42 +0800 +Subject: [PATCH] example_plugin: Add check after malloc allocation + +Reference:https://github.com/rpm-software-management/libdnf/commit/466bd9dd8b8836af34f29976a5b0b83950bbe8ed +Conflict:NA + +--- + plugins/example_plugin.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/plugins/example_plugin.c b/plugins/example_plugin.c +index 3f1b119f31..a12439bffd 100644 +--- a/plugins/example_plugin.c ++++ b/plugins/example_plugin.c +@@ -78,9 +78,11 @@ PluginHandle * pluginInitHandle(int version, PluginMode mode, DnfPluginInitData + break; + } + handle = malloc(sizeof(*handle)); +- handle->mode = mode; +- handle->context = pluginGetContext(initData); +- handle->outStream = outStream; ++ if (handle) { ++ handle->mode = mode; ++ handle->context = pluginGetContext(initData); ++ handle->outStream = outStream; ++ } + } while (0); + + fprintf(outStream, "%s: %s: exit =========================\n", info.name, __func__); diff --git a/libdnf.spec b/libdnf.spec index d0aa8d6..121b52f 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -18,7 +18,7 @@ Name: libdnf Version: 0.69.0 -Release: 3 +Release: 4 Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf @@ -44,6 +44,7 @@ Patch6000: backport-query-py-ensure-reldep-is-from-the-same-sack %ifarch loongarch64 Patch6001: 0001-libdnf-0.65.0-add-loongarch-support.patch %endif +Patch6002: backport-Add-check-after-malloc-allocation.patch %description A Library providing simplified C and Python API to libsolv. @@ -123,6 +124,9 @@ popd %{python3_sitearch}/hawkey/ %changelog +* Fri Apr 21 2023 zhangrui - 0.69.0-4 +- DESC:add check after malloc allocation + * Thu Jan 5 2023 zhangrui - 0.69.0-3 - DESC:add loongarch -- Gitee