Sync from SUSE:SLFO:Main iniparser revision b699f30ae8d8ca56663864ee0c4a9459

This commit is contained in:
Adrian Schröter 2024-06-12 22:30:19 +02:00
parent 34b8139b13
commit d5d2dba48e
8 changed files with 31 additions and 213 deletions

View File

@ -1,51 +0,0 @@
From b7a2c2999aabf2a83ccc164b9729259ea400e747 Mon Sep 17 00:00:00 2001
From: Dan Bungert <daniel.bungert@canonical.com>
Date: Thu, 18 Feb 2021 17:35:58 -0700
Subject: [PATCH] Fail testrun on test failure
Test failures can go unnoticed, as currently the test runner
unconditionally returns exit code 0. Consult the number of test
failures and exit code 1 if there are any.
---
test/make-tests.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/test/make-tests.sh b/test/make-tests.sh
index f2a3f2a..78e6901 100755
--- a/test/make-tests.sh
+++ b/test/make-tests.sh
@@ -26,10 +26,11 @@ cat $FILES | grep '^void Test' |
echo \
'
-void RunAllTests(void)
+int RunAllTests(void)
{
CuString *output = CuStringNew();
CuSuite* suite = CuSuiteNew();
+ int ret = 0;
'
cat $FILES | grep '^void Test' |
@@ -42,15 +43,16 @@ echo \
'
CuSuiteRun(suite);
CuSuiteSummary(suite, output);
+ if (suite->failCount > 0) ret = 1;
CuSuiteDetails(suite, output);
printf("%s\n", output->buffer);
CuStringDelete(output);
CuSuiteDelete(suite);
+ return ret;
}
int main(void)
{
- RunAllTests();
- return 0;
+ return RunAllTests();
}
'
--
2.37.1

View File

@ -1,49 +0,0 @@
From 1bd7c8341fc076a4795638330bc6badb78745647 Mon Sep 17 00:00:00 2001
From: James Larrowe <larrowe.semaj11@gmail.com>
Date: Sun, 9 Jun 2019 12:45:28 -0400
Subject: [PATCH] Fix buffer overflow from sprintf
Extension of #104 that includes tests
---
src/iniparser.c | 2 +-
test/test_iniparser.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/iniparser.c b/src/iniparser.c
index fffdf9f..f1d1658 100644
--- a/src/iniparser.c
+++ b/src/iniparser.c
@@ -718,7 +718,7 @@ dictionary * iniparser_load(const char * ininame)
char line [ASCIILINESZ+1] ;
char section [ASCIILINESZ+1] ;
char key [ASCIILINESZ+1] ;
- char tmp [(ASCIILINESZ * 2) + 1] ;
+ char tmp [(ASCIILINESZ * 2) + 2] ;
char val [ASCIILINESZ+1] ;
int last=0 ;
diff --git a/test/test_iniparser.c b/test/test_iniparser.c
index c76529c..b7cd5fc 100644
--- a/test/test_iniparser.c
+++ b/test/test_iniparser.c
@@ -96,7 +96,7 @@ void Test_iniparser_strstrip(CuTest *tc)
};
const char *test_with_spaces = "I am a test with\tspaces.";
char stripped[ASCIILINESZ+1];
- char error_msg[128];
+ char error_msg[1060];
unsigned i;
/* NULL ptr as input */
@@ -595,7 +595,7 @@ void Test_iniparser_load(CuTest *tc)
struct dirent *curr;
struct stat curr_stat;
dictionary *dic;
- char ini_path[256];
+ char ini_path[276];
/* Dummy tests */
dic = iniparser_load("/you/shall/not/path");
--
2.37.1

View File

@ -1,59 +0,0 @@
From 0f5a112836be0d9c7db59b8c9b832979298e14cc Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Wed, 24 Aug 2022 20:49:08 +0200
Subject: [PATCH] Fix tests on 32bit
The long has different width on 32bit and 64bit.
Use predefined macro for the maximum value.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
test/test_iniparser.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/test/test_iniparser.c b/test/test_iniparser.c
index b7cd5fc..020e6ae 100644
--- a/test/test_iniparser.c
+++ b/test/test_iniparser.c
@@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <stdarg.h>
+#include <limits.h>
#include "CuTest.h"
#include "dictionary.h"
@@ -15,6 +16,8 @@
#define GOOD_INI_PATH "ressources/good_ini"
#define BAD_INI_PATH "ressources/bad_ini"
+#define stringify_2(x...) #x
+#define stringify(x...) stringify_2(x)
/* Tool function to create and populate a generic non-empty dictionary */
static dictionary * generate_dictionary(unsigned sections, unsigned entries_per_section)
@@ -350,8 +353,8 @@ void Test_iniparser_getlongint(CuTest *tc)
{ 1000, "1000" },
{ 077, "077" },
{ -01000, "-01000" },
- { 0x7FFFFFFFFFFFFFFF, "0x7FFFFFFFFFFFFFFF" },
- { -0x7FFFFFFFFFFFFFFF, "-0x7FFFFFFFFFFFFFFF" },
+ { LONG_MAX, stringify(LONG_MAX) },
+ { -LONG_MAX, stringify(-LONG_MAX) },
{ 0x4242, "0x4242" },
{ 0, NULL} /* must be last */
};
@@ -370,8 +373,8 @@ void Test_iniparser_getlongint(CuTest *tc)
/* Check the def return element */
dic = dictionary_new(10);
CuAssertLongIntEquals(tc, 42, iniparser_getlongint(dic, "dummy", 42));
- CuAssertLongIntEquals(tc, 0x7FFFFFFFFFFFFFFF, iniparser_getlongint(dic, NULL, 0x7FFFFFFFFFFFFFFF));
- CuAssertLongIntEquals(tc, -0x7FFFFFFFFFFFFFFF, iniparser_getlongint(dic, "dummy", -0x7FFFFFFFFFFFFFFF));
+ CuAssertLongIntEquals(tc, LONG_MAX, iniparser_getlongint(dic, NULL, LONG_MAX));
+ CuAssertLongIntEquals(tc, -LONG_MAX, iniparser_getlongint(dic, "dummy", -LONG_MAX));
dictionary_del(dic);
/* Generic dictionary */
--
2.37.1

View File

@ -1,43 +0,0 @@
From ace9871f65d11b5d73f0b9ee8cf5d2807439442d Mon Sep 17 00:00:00 2001
From: Antonio <antoniolrt@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.
---
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') {

BIN
iniparser-4.1.tar.gz (Stored with Git LFS)

Binary file not shown.

BIN
iniparser-4.2.1.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Wed May 15 19:07:26 UTC 2024 - Michal Suchanek <msuchanek@suse.com>
- Update to version 4.2.1
* Fix parsing of section names containing whitespace
* Add support for escaped quotes, semicolon and hash in quoted values
* Do not close file in iniparser_load_file
* Add function description to header
* Add support for loading string/custom streams
* Update README.md
* Handle potential calloc failures in dictionary_new
* Add example showing how to write INI files
* Add support for uint64_t
* Fix tests on 32bit
* Prevent `long int` overflow on 32bit architectures
* Fail testrun on test failure
* add NULL check in dictionary_get
* Fix buffer overflow from sprintf
- Remove patches merged upstream
* Fail-testrun-on-test-failure.patch
* Fix-buffer-overflow-from-sprintf.patch
* Fix-tests-on-32bit.patch
* handle-null-return-getstring.patch
-------------------------------------------------------------------
Fri Jun 2 18:36:09 UTC 2023 - Antonio Teixeira <antonio.teixeira@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package iniparser
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -19,7 +19,7 @@
# if bumping this, also update baselibs.conf
%define sonum 1
Name: iniparser
Version: 4.1
Version: 4.2.1
Release: 0
Summary: Library to parse ini files
License: MIT
@ -28,12 +28,7 @@ URL: http://ndevilla.free.fr/iniparser/
Source: https://github.com/ndevilla/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source2: baselibs.conf
Patch00: iniparser_remove_rpath.patch
Patch01: Fail-testrun-on-test-failure.patch
Patch02: Fix-buffer-overflow-from-sprintf.patch
Patch03: Fix-tests-on-32bit.patch
# PATCH-FIX-SUSE handle-null-return-getstring.patch bsc#1211889 -- CVE-2023-33461: NULL pointer dereference in iniparser_getboolean()
# https://github.com/ndevilla/iniparser/pull/146
Patch04: handle-null-return-getstring.patch
BuildRequires: doxygen
%description
Libiniparser offers parsing of ini files from the C level.
@ -80,6 +75,7 @@ Libraries and Header Files to Develop Programs with iniparser Support.
%build
make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC"
make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC" docs
%install
install -d -m 0755 %{buildroot}%{_includedir}