Dominique Leuenberger 9 months ago committed by Git OBS Bridge
commit b03977d68d

@ -0,0 +1,51 @@
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

@ -0,0 +1,49 @@
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

@ -0,0 +1,59 @@
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

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Aug 24 18:26:33 UTC 2022 - Michal Suchanek <msuchanek@suse.com>
- Add fixes since 4.1
+ Fail-testrun-on-test-failure.patch
+ Fix-buffer-overflow-from-sprintf.patch
- Fix tests failing on 32bit architectures
+ Fix-tests-on-32bit.patch
-------------------------------------------------------------------
Sat Nov 11 05:21:56 UTC 2017 - aavindraa@gmail.com

@ -1,7 +1,7 @@
#
# spec file for package iniparser
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -28,6 +28,9 @@ 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
%description
Libiniparser offers parsing of ini files from the C level.
@ -70,7 +73,7 @@ Libraries and Header Files to Develop Programs with iniparser Support.
%prep
%setup -q
%patch00 -p1
%autopatch -p1
%build
make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC"

Loading…
Cancel
Save