From 3431a678462fcb4a88b3681562dfc6d7bb9e7a78 Mon Sep 17 00:00:00 2001 From: yuanhui Date: Fri, 9 Dec 2022 16:15:27 +0800 Subject: [PATCH] Add abi files and fixed coverity issues Signed-off-by: yuanhui --- 0001-which-2.21-coverity-fixes.patch | 65 ++++++++++++++++++++++++++++ which.spec | 15 +++++-- 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 0001-which-2.21-coverity-fixes.patch diff --git a/0001-which-2.21-coverity-fixes.patch b/0001-which-2.21-coverity-fixes.patch new file mode 100644 index 0000000..fbcb636 --- /dev/null +++ b/0001-which-2.21-coverity-fixes.patch @@ -0,0 +1,65 @@ +diff -up which-2.21/tilde/tilde.c.coverity which-2.21/tilde/tilde.c +--- which-2.21/tilde/tilde.c.coverity 2008-01-16 18:51:57.000000000 +0100 ++++ which-2.21/tilde/tilde.c 2021-03-21 11:43:00.338160051 +0100 +@@ -193,10 +193,10 @@ tilde_expand (string) + const char *string; + { + char *result; +- int result_size, result_index; ++ int result_size = 0, result_index = 0; + +- result_index = result_size = 0; +- if (result = strchr (string, '~')) ++ result = strchr (string, '~'); ++ if (result) + result = (char *)xmalloc (result_size = (strlen (string) + 16)); + else + result = (char *)xmalloc (result_size = (strlen (string) + 1)); +@@ -270,7 +270,7 @@ isolate_tilde_prefix (fname, lenp) + char *ret; + int i; + +- ret = (char *)xmalloc (strlen (fname)); ++ ret = (char *)xmalloc (strlen (fname) + 1); + #if defined (__MSDOS__) + for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++) + #else +diff -up which-2.21/which.c.coverity which-2.21/which.c +--- which-2.21/which.c.coverity 2015-03-19 17:50:24.000000000 +0100 ++++ which-2.21/which.c 2021-03-21 12:19:31.289160885 +0100 +@@ -76,16 +76,16 @@ static int skip_functions = 0, read_func + + static char *find_command_in_path(const char *name, const char *path_list, int *path_index) + { +- char *found = NULL, *full_path; ++ char *found = NULL, *full_path = NULL; + int status, name_len; + + name_len = strlen(name); ++ char *p; + + if (!absolute_program(name)) + absolute_path_given = 0; + else + { +- char *p; + absolute_path_given = 1; + + if (abs_path) +@@ -159,6 +159,7 @@ static char *find_command_in_path(const + free(full_path); + } + ++ name = NULL; p = NULL; path_list = NULL; + return (found); + } + +@@ -540,7 +541,7 @@ int main(int argc, char *argv[]) + int function_start_type = 0; + if (read_alias || read_functions) + { +- char buf[1024]; ++ char buf[1024] = {}; + int processing_aliases = read_alias; + + if (isatty(0)) diff --git a/which.spec b/which.spec index 9e6072c..ff8995c 100644 --- a/which.spec +++ b/which.spec @@ -1,4 +1,4 @@ -%define anolis_release 2 +%define anolis_release 3 Name: which Version: 2.21 Release: %{anolis_release}%{?dist} @@ -8,7 +8,9 @@ License: GPLv3 URL: https://savannah.gnu.org/projects/which/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.gz Source1: which2.sh -Source2: which2.csh +Source2: which2.csh + +Patch0: 0001-which-2.21-coverity-fixes.patch BuildRequires: make gcc readline-devel @@ -25,7 +27,7 @@ BuildArch: noarch The %{name}-doc package contains documentation files for %{name}. %prep -%autosetup +%autosetup -p1 %build @@ -41,10 +43,13 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d install -p -m 644 %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/ rm -f $RPM_BUILD_ROOT%{_infodir}/dir +%generate_compatibility_deps + %files %license COPYING %attr(0644,root,root) %{_sysconfdir}/profile.d/which2.* %{_bindir}/which +%{abidir}/%{name}*-option.list %{_infodir}/which.info* %{_mandir}/man1/which.1* @@ -52,6 +57,10 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %doc EXAMPLES README AUTHORS NEWS %changelog +* Fri Dec 09 2022 yuanhui - 2.21-3 +- add abi files +- fixed coverity issues for which + * Sat Oct 08 2022 mgb01105731 - 2.21-2 - add doc package -- Gitee