From b563fd9014c0738907ee8a4da259dfdd0385f60b Mon Sep 17 00:00:00 2001 From: Jakub Martisko Date: Tue, 16 Nov 2021 14:26:28 +0100 Subject: [PATCH] Add annotations to disable false positives reported by the covscan Related: rhbz#1938867 --- sed-covscan-annotations.patch | 60 +++++++++++++++++++++++++++++++++++ sed.spec | 8 ++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 sed-covscan-annotations.patch diff --git a/sed-covscan-annotations.patch b/sed-covscan-annotations.patch new file mode 100644 index 0000000..0679ed4 --- /dev/null +++ b/sed-covscan-annotations.patch @@ -0,0 +1,60 @@ +From 87f411a001394948183aaf389c711f3837c361b5 Mon Sep 17 00:00:00 2001 +From: Jakub Martisko +Date: Mon, 15 Nov 2021 16:06:54 +0100 +Subject: [PATCH] covscan annotations + +--- + lib/malloca.c | 3 ++- + sed/compile.c | 2 ++ + sed/utils.c | 1 + + 3 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/lib/malloca.c b/lib/malloca.c +index 975b166..36e2342 100644 +--- a/lib/malloca.c ++++ b/lib/malloca.c +@@ -64,7 +64,8 @@ mmalloca (size_t n) + [mem, mem + nplus). */ + ((small_t *) p)[-1] = p - mem; + /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ +- return p; ++ /* cppcheck-suppress memleak */ ++ return p; + } + } + /* Out of memory. */ +diff --git a/sed/compile.c b/sed/compile.c +index 8321d68..df42794 100644 +--- a/sed/compile.c ++++ b/sed/compile.c +@@ -829,6 +829,7 @@ setup_replacement (struct subst *sub, const char *text, size_t length) + + tail->next = NULL; + sub->replacement = root.next; ++ /* coverity [leaked_storage] */ + } + + static void +@@ -1312,6 +1313,7 @@ compile_program (struct vector *vector) + bad_prog (_(Y_CMD_LEN)); + + IF_LINT (free (src_lens)); ++ /* coverity [leaked_storage] */ + } + else + { +diff --git a/sed/utils.c b/sed/utils.c +index 371d5a9..0d68f60 100644 +--- a/sed/utils.c ++++ b/sed/utils.c +@@ -294,6 +294,7 @@ do_ck_fclose (FILE *fp) + clearerr (fp); + + if (fclose (fp) == EOF) ++ /* coverity[pass_freed_arg] */ + panic ("couldn't close %s: %s", utils_fp_name (fp), strerror (errno)); + } + +-- +2.33.0 + diff --git a/sed.spec b/sed.spec index 0923c36..33f9990 100644 --- a/sed.spec +++ b/sed.spec @@ -3,13 +3,14 @@ Summary: A GNU stream text editor Name: sed Version: 4.8 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv3+ URL: http://sed.sourceforge.net/ Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.xz Source1: http://sed.sourceforge.net/sedfaq.txt Patch0: sed-b-flag.patch Patch1: sed-c-flag.patch +Patch2: sed-covscan-annotations.patch BuildRequires: make BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf, gcc BuildRequires: perl-Getopt-Long @@ -31,6 +32,7 @@ specified in a script file or from the command line. %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 sed -e 's/1729576/EPERM/' \ @@ -63,6 +65,10 @@ rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir %{_mandir}/man1/sed.1* %changelog +* Tue Nov 16 2021 Jakub Martisko - 4.8-9 +- Add annotations to disable false positives in the covscan +- Related: rhbz#1938867 + * Fri Jul 23 2021 Fedora Release Engineering - 4.8-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild