From: Soumya Sambu <soumya.sa...@windriver.com>

iniparser v4.1 is vulnerable to NULL Pointer Dereference
in function iniparser_getlongint which misses check NULL
for function iniparser_getstring's return.

References:
https://nvd.nist.gov/vuln/detail/CVE-2023-33461

Signed-off-by: Soumya Sambu <soumya.sa...@windriver.com>
---
 .../iniparser/iniparser/CVE-2023-33461.patch  | 51 +++++++++++++++++++
 .../iniparser/iniparser_4.1.bb                |  4 +-
 2 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 
meta-oe/recipes-support/iniparser/iniparser/CVE-2023-33461.patch

diff --git a/meta-oe/recipes-support/iniparser/iniparser/CVE-2023-33461.patch 
b/meta-oe/recipes-support/iniparser/iniparser/CVE-2023-33461.patch
new file mode 100644
index 000000000..1b577fa33
--- /dev/null
+++ b/meta-oe/recipes-support/iniparser/iniparser/CVE-2023-33461.patch
@@ -0,0 +1,51 @@
+From ace9871f65d11b5d73f0b9ee8cf5d2807439442d Mon Sep 17 00:00:00 2001
+From: Antonio <antonio...@gmail.com>
+Date: Fri, 2 Jun 2023 15:03:10 -0300
+Subject: [PATCH] Handle null return from iniparser_getstring
+
+Fix handling of NULL returns from iniparser_getstring in
+iniparser_getboolean, iniparser_getlongint and iniparser_getdouble,
+avoiding a crash.
+
+CVE: CVE-2023-33461
+
+Upstream-Status: Backport 
[https://github.com/ndevilla/iniparser/commit/ace9871f65d11b5d73f0b9ee8cf5d2807439442d]
+
+Signed-off-by: Soumya Sambu <soumya.sa...@windriver.com>
+---
+ 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') 
{
+--
+2.40.0
diff --git a/meta-oe/recipes-support/iniparser/iniparser_4.1.bb 
b/meta-oe/recipes-support/iniparser/iniparser_4.1.bb
index 2810a4f65..7c23b514b 100644
--- a/meta-oe/recipes-support/iniparser/iniparser_4.1.bb
+++ b/meta-oe/recipes-support/iniparser/iniparser_4.1.bb
@@ -10,7 +10,9 @@ PV .= "+git${SRCPV}"
 
 SRC_URI = 
"git://github.com/ndevilla/iniparser.git;protocol=https;branch=master \
            file://0001-iniparser.pc-Make-libpath-a-variable.patch \
-          file://Add-CMake-support.patch"
+          file://Add-CMake-support.patch \
+           file://CVE-2023-33461.patch \
+"
 
 SRCREV= "deb85ad4936d4ca32cc2260ce43323d47936410d"
 
-- 
2.40.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#109663): 
https://lists.openembedded.org/g/openembedded-devel/message/109663
Mute This Topic: https://lists.openembedded.org/mt/105195151/21656
Group Owner: openembedded-devel+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to