From 6f11dd16d02c324d17b9cfae9e81179b53183c80 Mon Sep 17 00:00:00 2001 From: wk333 <13474090681@163.com> Date: Sun, 25 Jun 2023 10:23:05 +0800 Subject: [PATCH] Fix CVE-2023-33461 (cherry picked from commit ae79b42632c78225b2638649aae87faa13505e8a) --- CVE-2023-33461.patch | 45 ++++++++++++++++++++++++++++++++++++++++++++ iniparser.spec | 8 ++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 CVE-2023-33461.patch diff --git a/CVE-2023-33461.patch b/CVE-2023-33461.patch new file mode 100644 index 0000000..ac03187 --- /dev/null +++ b/CVE-2023-33461.patch @@ -0,0 +1,45 @@ +From ace9871f65d11b5d73f0b9ee8cf5d2807439442d Mon Sep 17 00:00:00 2001 +From: Antonio +Date: Fri, 2 Jun 2023 15:03:10 -0300 +Subject: [PATCH] Handle null return from iniparser_getstring + +Origin: https://github.com/ndevilla/iniparser/pull/146 + +Fix handling of NULL returns from iniparser_getstring in +iniparser_getboolean, iniparser_getlongint and iniparser_getdouble, +avoiding a crash. +--- + src/iniparser.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/iniparser.c b/src/iniparser.c +index f1d1658..dbceb20 100644 +--- a/src/iniparser.c ++++ b/src/iniparser.c +@@ -456,7 +456,7 @@ long int iniparser_getlongint(const dictionary * d, const char * key, long int n + const char * str ; + + str = iniparser_getstring(d, key, INI_INVALID_KEY); +- if (str==INI_INVALID_KEY) return notfound ; ++ if (str==NULL || str==INI_INVALID_KEY) return notfound ; + return strtol(str, NULL, 0); + } + +@@ -511,7 +511,7 @@ double iniparser_getdouble(const dictionary * d, const char * key, double notfou + const char * str ; + + str = iniparser_getstring(d, key, INI_INVALID_KEY); +- if (str==INI_INVALID_KEY) return notfound ; ++ if (str==NULL || str==INI_INVALID_KEY) return notfound ; + return atof(str); + } + +@@ -553,7 +553,7 @@ int iniparser_getboolean(const dictionary * d, const char * key, int notfound) + const char * c ; + + c = iniparser_getstring(d, key, INI_INVALID_KEY); +- if (c==INI_INVALID_KEY) return notfound ; ++ if (c==NULL || c==INI_INVALID_KEY) return notfound ; + if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') { + ret = 1 ; + } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') { diff --git a/iniparser.spec b/iniparser.spec index 92393a2..8a2908e 100644 --- a/iniparser.spec +++ b/iniparser.spec @@ -2,11 +2,12 @@ Name: iniparser Version: 4.1 -Release: 3 +Release: 4 Summary: ini file parser License: MIT and Zlib URL: https://github.com/ndevilla/iniparser Source0: https://github.com/ndevilla/iniparser/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: CVE-2023-33461.patch BuildRequires: gcc doxygen @@ -14,7 +15,7 @@ BuildRequires: gcc doxygen This modules offers parsing of ini files from the C level. See a complete documentation in HTML format, from this directory open the file html/index.html with any HTML-capable browser. %prep -%setup -q -n %{name}-%{version}/ +%autosetup -n %{name}-%{version} -p1 %build %make_build @@ -48,6 +49,9 @@ cp -r html %{buildroot}/%{_docdir}/%{name} %{_docdir}/* %changelog +* Sun Jun 25 2023 wangkai <13474090681@163.com> - 4.1-4 +- Fix CVE-2023-33461 + * Tue Jan 19 2021 Ge Wang - 4.1-3 - Modify license information. -- Gitee