From 82ea9f483fbc39bb20bf48d3819317ba78f53873 Mon Sep 17 00:00:00 2001 From: wu-leilei Date: Mon, 20 Dec 2021 10:29:19 +0800 Subject: [PATCH] fix mem_size overflow --- fix-mem_size-overflow.patch | 41 +++++++++++++++++++++++++++++++++++++ hiredis.spec | 6 +++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 fix-mem_size-overflow.patch diff --git a/fix-mem_size-overflow.patch b/fix-mem_size-overflow.patch new file mode 100644 index 0000000..b3392cc --- /dev/null +++ b/fix-mem_size-overflow.patch @@ -0,0 +1,41 @@ +From 299246408d3442a3240ccf25ce31c08ecee64766 Mon Sep 17 00:00:00 2001 +From: wu-leilei +Date: Mon, 20 Dec 2021 10:14:35 +0800 +Subject: [PATCH] fix mem_size overflow + +--- + alloc.h | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/alloc.h b/alloc.h +index 34a05f4..89cb727 100644 +--- a/alloc.h ++++ b/alloc.h +@@ -33,6 +33,11 @@ + + #include /* for size_t */ + ++#ifndef _WIN32 ++#include ++#include ++#endif ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -55,6 +60,12 @@ void hiredisResetAllocators(void); + extern hiredisAllocFuncs hiredisAllocFns; + + static inline void *hi_malloc(size_t size) { ++#ifndef _WIN32 ++ struct sysinfo s_info; ++ int error; ++ if((error = sysinfo(&s_info)) < 0) return NULL; ++ if(s_info.totalram < size) return NULL; ++#endif + return hiredisAllocFns.mallocFn(size); + } + +-- +2.23.0 + diff --git a/hiredis.spec b/hiredis.spec index be2ff34..2c386d0 100644 --- a/hiredis.spec +++ b/hiredis.spec @@ -1,6 +1,6 @@ Name: hiredis Version: 1.0.2 -Release: 1 +Release: 2 Summary: A minimalistic C client library for the Redis database License: BSD URL: https://github.com/redis/hiredis @@ -8,6 +8,7 @@ Source0: https://github.com/redis/hiredis/archive/refs/tags/v%{version}.t BuildRequires: gcc redis Patch0001: fix-heap-buffer-overflow-in-redisvFormatCommand.patch +Patch0002: fix-mem_size-overflow.patch %description Hiredis is a minimalistic C client library for the Redis database. @@ -60,6 +61,9 @@ make check || true %{_libdir}/pkgconfig/hiredis.pc %changelog +* Mon Dec 20 2021 wulei - 1.0.2-2 +- Fix mem_size overflow + * Mon Oct 11 2021 houyingchao - 1.0.2-1 - Fix CVE-2021-32765