Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
d34f505418
!29 [sync] PR-24: fixed coverity issues
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-11-27 04:13:12 +00:00
fandeyuan
c91a3f9fd0 coverity fixes
(cherry picked from commit f6bb7b4816c5c690a740bca61c7d567a0622fa5e)
2024-11-21 16:53:07 +08:00
openeuler-ci-bot
d2dda76f32
!11 fix:which fails for long path
From: @fandeyuan 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2024-05-10 01:25:20 +00:00
fandeyuan
1124b8285f which fails for long path 2024-04-30 14:25:06 +08:00
openeuler-ci-bot
60c3d4bb4e
!8 【轻量级 PR】:Remove unnecessary -S git
From: @yangzhao_kl 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
2022-06-21 03:31:14 +00:00
yangzhao_kl
0ff6b50a80
Remove unnecessary -S git 2022-06-21 01:30:02 +00:00
openeuler-ci-bot
00cbbbafef
!4 【轻量级PR】修正changelog中的错误日期
From: @konglidong 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2022-06-15 08:39:21 +00:00
konglidong
8e380e94a3 modify bogus date in changelog 2022-06-15 16:11:43 +08:00
openeuler-ci-bot
cf18d6c40a !2 add yaml file in package
Merge pull request !2 from Markeryang/master
2020-07-02 16:48:42 +08:00
Markeryang
a7445acfc8 add which.yaml. 2020-07-02 15:54:38 +08:00
4 changed files with 166 additions and 4 deletions

View File

@ -0,0 +1,59 @@
From 77420bf2e35444f348b19e0acaf1f77bb4ed3f76 Mon Sep 17 00:00:00 2001
From: fandeyuan <fandeyuan@kylinos.cn>
Date: Tue, 30 Apr 2024 14:18:20 +0800
Subject: [PATCH] which fails for long path
---
which.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/which.c b/which.c
index 1606052..525c0d0 100644
--- a/which.c
+++ b/which.c
@@ -19,10 +19,15 @@
#include "sys.h"
#include <stdio.h>
#include <ctype.h>
+#include <limits.h>
#include "getopt.h"
#include "tilde/tilde.h"
#include "bash.h"
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
static const char *progname;
static void print_usage(FILE *out)
@@ -63,7 +68,7 @@ static void print_fail(const char *name, const char *path_list)
fprintf(stderr, "%s: no %s in (%s)\n", progname, name, path_list);
}
-static char home[256];
+static char home[PATH_MAX];
static size_t homelen = 0;
static int absolute_path_given;
@@ -162,7 +167,7 @@ static char *find_command_in_path(const char *name, const char *path_list, int *
return (found);
}
-static char cwd[256];
+static char cwd[PATH_MAX];
static size_t cwdlen;
static void get_current_working_directory(void)
@@ -194,7 +199,7 @@ static void get_current_working_directory(void)
static char *path_clean_up(const char *path)
{
- static char result[256];
+ static char result[PATH_MAX];
const char *p1 = path;
char *p2 = result;
--
2.33.0

80
0002-coverity-fixes.patch Normal file
View File

@ -0,0 +1,80 @@
From 741e8fa0ee62563589870592071188d6391ead38 Mon Sep 17 00:00:00 2001
From: Than Ngo <than@redhat.com>
Date: Sun, 21 Mar 2021 18:34:09 +0000
Subject: [PATCH] coverity fixes
---
tilde/tilde.c | 8 ++++----
which.c | 7 ++++---
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/tilde/tilde.c b/tilde/tilde.c
index 1b76c9f..b393506 100644
--- a/tilde/tilde.c
+++ b/tilde/tilde.c
@@ -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 --git a/which.c b/which.c
index 525c0d0..9f93021 100644
--- a/which.c
+++ b/which.c
@@ -81,16 +81,16 @@ static int skip_functions = 0, read_functions = 0;
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)
@@ -164,6 +164,7 @@ static char *find_command_in_path(const char *name, const char *path_list, int *
free(full_path);
}
+ name = NULL; p = NULL; path_list = NULL;
return (found);
}
@@ -545,7 +546,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))
--
2.43.0

View File

@ -1,12 +1,15 @@
Name: which
Version: 2.21
Release: 14
Release: 17
Summary: Show the full path of commands
License: GPLv3
URL: https://savannah.gnu.org/projects/which/
Source0: http://ftp.gnu.org/gnu/which/%{name}-%{version}.tar.gz
BuildRequires: gcc git
Patch1: 0001-which-fails-for-long-path.patch
Patch2: 0002-coverity-fixes.patch
BuildRequires: gcc
%description
Which takes one or more arguments. For each of its arguments it prints to stdout
@ -19,7 +22,7 @@ Summary: Help files for which
Contains documents and manuals files for which
%prep
%autosetup -n %{name}-%{version} -p1 -S git
%autosetup -n %{name}-%{version} -p1
%build
%configure
@ -40,13 +43,28 @@ rm -f %{buildroot}/%{_datadir}/info/dir
%{_datadir}/info/%{name}.info.gz
%changelog
* Thu Nov 21 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 2.21-17
- fixed coverity issues
* Tue Apr 30 2024 Deyuan Fan <fandeyuan@kylinos.cn> - 2.21-16
- Type: bugfix
- ID: NA
- SUG: NA
- DESC: fix:which fails for long path
* Mon Jun 20 2022 yangzhao <yangzhao1@kylinos.cn> - 2.21-15
- Type: enhancement
- ID: NA
- SUG: NA
- DESC: remove unnecessary -S git
* Wed Jan 8 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.21-14
- Type: enhancement
- ID: NA
- SUG: NA
- DESC: remove unnecessary files
* Wed Oct 10 2019 luhuaxin <luhuaxin@huawei.com> - 2.21-13
* Thu Oct 10 2019 luhuaxin <luhuaxin@huawei.com> - 2.21-13
- Type: enhancement
- ID: NA
- SUG: NA

5
which.yaml Normal file
View File

@ -0,0 +1,5 @@
version_control: NA
src_repo:
tag_prefix:
seperator:
url: http://ftp.gnu.org/gnu/which/