Compare commits

...

No commits in common. "c9-beta" and "c10s" have entirely different histories.

22 changed files with 415 additions and 250 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/tree-1.8.0.tgz /tree-[1-9].*.*.tgz

View File

@ -1 +0,0 @@
06934bf1f6a92af4eaec6bc61e568cec5e068ba1 SOURCES/tree-1.8.0.tgz

View File

@ -1,16 +0,0 @@
color.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/color.c b/color.c
index 67dedbe..bbcc9df 100644
--- a/color.c
+++ b/color.c
@@ -191,7 +191,7 @@ void parse_dir_colors()
if (!norm_flgs) norm_flgs = scopy("00");
if (!endcode) {
- sprintf(buf,"%s%s%s",leftcode,norm_flgs,rightcode);
+ sprintf(buf,"%s0%s",leftcode,rightcode);
endcode = scopy(buf);
}

View File

@ -1,19 +0,0 @@
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 842281e..ee7fbe6 100644
--- a/Makefile
+++ b/Makefile
@@ -112,9 +112,9 @@ install: tree
install -d $(BINDIR)
install -d $(MANDIR)
if [ -e $(TREE_DEST) ]; then \
- install $(TREE_DEST) $(BINDIR)/$(TREE_DEST); \
+ install -p $(TREE_DEST) $(BINDIR)/$(TREE_DEST); \
fi
- install doc/$(MAN) $(MANDIR)/$(MAN)
+ install -p doc/$(MAN) $(MANDIR)/$(MAN)
distclean:
if [ -f tree.o ]; then rm *.o; fi

View File

@ -1,189 +0,0 @@
From 48641275c0cd018441685f2d3145038017f1ea42 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Tue, 6 Nov 2018 16:31:32 +0100
Subject: [PATCH] tree: fix programming mistakes detected by static analysis
---
html.c | 5 +++--
json.c | 11 +++++------
tree.c | 2 +-
unix.c | 5 +++--
xml.c | 11 +++++------
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/html.c b/html.c
index 75e2ed1..35fb525 100644
--- a/html.c
+++ b/html.c
@@ -221,7 +221,7 @@ off_t html_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
if (*(*dir)->lnk == '/')
listdir((*dir)->lnk,dt,ft,lev+1,dev);
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
listdir(path,dt,ft,lev+1,dev);
@@ -254,7 +254,7 @@ off_t html_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
{
struct _info **dir;
off_t size = 0;
- char *err;
+ char *err = NULL;
dir = getfulltree(d, lev, dev, &size, &err);
@@ -262,6 +262,7 @@ off_t html_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
htmlr_listdir(dir, d, dt, ft, lev);
+ free(err);
return size;
}
diff --git a/json.c b/json.c
index 4b15e0d..8c71324 100644
--- a/json.c
+++ b/json.c
@@ -98,8 +98,7 @@ off_t json_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
while(*dir) {
if (!noindent) json_indent(lev);
- if ((*dir)->lnk) mt = (*dir)->mode & S_IFMT;
- else mt = (*dir)->mode & S_IFMT;
+ mt = (*dir)->mode & S_IFMT;
for(t=0;ifmt[t];t++)
if (ifmt[t] == mt) break;
fprintf(outfile,"{\"type\":\"%s\"", ftype[t]);
@@ -141,7 +140,7 @@ off_t json_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
if (*(*dir)->lnk == '/')
listdir((*dir)->lnk,dt,ft,lev+1,dev);
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
listdir(path,dt,ft,lev+1,dev);
@@ -181,7 +180,7 @@ off_t json_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
{
struct _info **dir;
off_t size = 0;
- char *err;
+ char *err = NULL;
dir = getfulltree(d, lev, dev, &size, &err);
@@ -189,6 +188,7 @@ off_t json_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
jsonr_listdir(dir, d, dt, ft, lev);
+ free(err);
return size;
}
@@ -211,8 +211,7 @@ void jsonr_listdir(struct _info **dir, char *d, int *dt, int *ft, u_long lev)
while(*dir) {
if (!noindent) json_indent(lev);
- if ((*dir)->lnk) mt = (*dir)->mode & S_IFMT;
- else mt = (*dir)->mode & S_IFMT;
+ mt = (*dir)->mode & S_IFMT;
for(t=0;ifmt[t];t++)
if (ifmt[t] == mt) break;
fprintf(outfile,"{\"type\":\"%s\"", ftype[t]);
diff --git a/tree.c b/tree.c
index 03140fe..73dd101 100644
--- a/tree.c
+++ b/tree.c
@@ -882,7 +882,7 @@ struct _info **unix_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, cha
if (*(*dir)->lnk == '/')
(*dir)->child = unix_getfulltree((*dir)->lnk,lev+1,dev,&((*dir)->size),&((*dir)->err));
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
(*dir)->child = unix_getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err));
diff --git a/unix.c b/unix.c
index ca5f76f..9476307 100644
--- a/unix.c
+++ b/unix.c
@@ -129,7 +129,7 @@ off_t unix_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
if (*(*dir)->lnk == '/')
listdir((*dir)->lnk,dt,ft,lev+1,dev);
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
listdir(path,dt,ft,lev+1,dev);
@@ -162,7 +162,7 @@ off_t unix_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
{
struct _info **dir;
off_t size = 0;
- char *err;
+ char *err = NULL;
dir = getfulltree(d, lev, dev, &size, &err);
@@ -170,6 +170,7 @@ off_t unix_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
r_listdir(dir, d, dt, ft, lev);
+ free(err);
return size;
}
diff --git a/xml.c b/xml.c
index 32f3c0c..512eed7 100644
--- a/xml.c
+++ b/xml.c
@@ -106,8 +106,7 @@ off_t xml_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
while(*dir) {
if (!noindent) xml_indent(lev);
- if ((*dir)->lnk) mt = (*dir)->mode & S_IFMT;
- else mt = (*dir)->mode & S_IFMT;
+ mt = (*dir)->mode & S_IFMT;
for(t=0;ifmt[t];t++)
if (ifmt[t] == mt) break;
fprintf(outfile,"<%s", ftype[t]);
@@ -145,7 +144,7 @@ off_t xml_listdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
if (*(*dir)->lnk == '/')
listdir((*dir)->lnk,dt,ft,lev+1,dev);
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
listdir(path,dt,ft,lev+1,dev);
@@ -181,7 +180,7 @@ off_t xml_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
{
struct _info **dir;
off_t size = 0;
- char *err;
+ char *err = NULL;
dir = getfulltree(d, lev, dev, &size, &err);
@@ -189,6 +188,7 @@ off_t xml_rlistdir(char *d, int *dt, int *ft, u_long lev, dev_t dev)
xmlr_listdir(dir, d, dt, ft, lev);
+ free(err);
return size;
}
@@ -211,8 +211,7 @@ void xmlr_listdir(struct _info **dir, char *d, int *dt, int *ft, u_long lev)
while(*dir) {
if (!noindent) xml_indent(lev);
- if ((*dir)->lnk) mt = (*dir)->mode & S_IFMT;
- else mt = (*dir)->mode & S_IFMT;
+ mt = (*dir)->mode & S_IFMT;
for(t=0;ifmt[t];t++)
if (ifmt[t] == mt) break;
fprintf(outfile,"<%s", ftype[t]);
--
2.17.2

1
ci.fmf Normal file
View File

@ -0,0 +1 @@
resultsdb-testcase: separate

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build./plans/tier1-internal.functional}
- !PassingTestCaseRule {test_case_name: osci.brew-build./plans/local.functional}

5
plans/local.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Run all local tests
discover:
how: fmf
execute:
how: tmt

10
plans/tier1-internal.fmf Normal file
View File

@ -0,0 +1,10 @@
summary: Internal gating tests plan
discover:
- how: fmf
filter: 'tag: Tier1, Tier2'
url: https://pkgs.devel.redhat.com/git/tests/tree
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream or distro == fedora

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (tree-2.1.0.tgz) = 17947b17e5fd4d06aea17be0cb107340a0537fb60cd5ee76524ef6eca37a775dbe9a4a7060d54f90a64ac1310131bf76b878fdb4384ab1a5fcb3180787c35a87

2
tests/tree-smoke/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/dir-tree
/tree.out

View File

@ -0,0 +1,7 @@
summary: Check whether `tree` works as expected.
test: ./runtest.sh
require:
- bash
- coreutils
- diffutils
- tree

39
tests/tree-smoke/runtest.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
# exit immediately if any command returns non-zero exit code
set -e
# print commands as they are executed by the shell interpreter
set -x
# set locale
export LANG=C
export LC_ALL=C
locale
# print basic info about `tree`
rpm -q tree
command -v tree
tree --version
ldd /usr/bin/tree
# create a testing directory tree
rm -rf dir-tree
mkdir dir-tree
(
set +x
cd dir-tree
for level in {1..16}; do
subdir=subdir-l${level}
touch {A,Z,a,z}-regular
ln -s a-regular symlink
ln -s $subdir dir-symlink
ln -s .. parent-dir-symlink
ln -s / root-dir-symlink
ln -s invalid danglging-symlink
mkdir -p $subdir
cd $subdir
done
)
tree dir-tree > tree.out
diff -u tree.{exp,out}

10
tests/tree-smoke/sync.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# print commands as they are executed by the shell interpreter
set -x
# run the test
./runtest.sh
# save current out put as the expected output
mv -v tree.{out,exp}

163
tests/tree-smoke/tree.exp Normal file
View File

@ -0,0 +1,163 @@
dir-tree
|-- A-regular
|-- Z-regular
|-- a-regular
|-- danglging-symlink -> invalid
|-- dir-symlink -> subdir-l1
|-- parent-dir-symlink -> ..
|-- root-dir-symlink -> /
|-- subdir-l1
| |-- A-regular
| |-- Z-regular
| |-- a-regular
| |-- danglging-symlink -> invalid
| |-- dir-symlink -> subdir-l2
| |-- parent-dir-symlink -> ..
| |-- root-dir-symlink -> /
| |-- subdir-l2
| | |-- A-regular
| | |-- Z-regular
| | |-- a-regular
| | |-- danglging-symlink -> invalid
| | |-- dir-symlink -> subdir-l3
| | |-- parent-dir-symlink -> ..
| | |-- root-dir-symlink -> /
| | |-- subdir-l3
| | | |-- A-regular
| | | |-- Z-regular
| | | |-- a-regular
| | | |-- danglging-symlink -> invalid
| | | |-- dir-symlink -> subdir-l4
| | | |-- parent-dir-symlink -> ..
| | | |-- root-dir-symlink -> /
| | | |-- subdir-l4
| | | | |-- A-regular
| | | | |-- Z-regular
| | | | |-- a-regular
| | | | |-- danglging-symlink -> invalid
| | | | |-- dir-symlink -> subdir-l5
| | | | |-- parent-dir-symlink -> ..
| | | | |-- root-dir-symlink -> /
| | | | |-- subdir-l5
| | | | | |-- A-regular
| | | | | |-- Z-regular
| | | | | |-- a-regular
| | | | | |-- danglging-symlink -> invalid
| | | | | |-- dir-symlink -> subdir-l6
| | | | | |-- parent-dir-symlink -> ..
| | | | | |-- root-dir-symlink -> /
| | | | | |-- subdir-l6
| | | | | | |-- A-regular
| | | | | | |-- Z-regular
| | | | | | |-- a-regular
| | | | | | |-- danglging-symlink -> invalid
| | | | | | |-- dir-symlink -> subdir-l7
| | | | | | |-- parent-dir-symlink -> ..
| | | | | | |-- root-dir-symlink -> /
| | | | | | |-- subdir-l7
| | | | | | | |-- A-regular
| | | | | | | |-- Z-regular
| | | | | | | |-- a-regular
| | | | | | | |-- danglging-symlink -> invalid
| | | | | | | |-- dir-symlink -> subdir-l8
| | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | |-- root-dir-symlink -> /
| | | | | | | |-- subdir-l8
| | | | | | | | |-- A-regular
| | | | | | | | |-- Z-regular
| | | | | | | | |-- a-regular
| | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | |-- dir-symlink -> subdir-l9
| | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | |-- subdir-l9
| | | | | | | | | |-- A-regular
| | | | | | | | | |-- Z-regular
| | | | | | | | | |-- a-regular
| | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | |-- dir-symlink -> subdir-l10
| | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | |-- subdir-l10
| | | | | | | | | | |-- A-regular
| | | | | | | | | | |-- Z-regular
| | | | | | | | | | |-- a-regular
| | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | |-- dir-symlink -> subdir-l11
| | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | |-- subdir-l11
| | | | | | | | | | | |-- A-regular
| | | | | | | | | | | |-- Z-regular
| | | | | | | | | | | |-- a-regular
| | | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | | |-- dir-symlink -> subdir-l12
| | | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | | |-- subdir-l12
| | | | | | | | | | | | |-- A-regular
| | | | | | | | | | | | |-- Z-regular
| | | | | | | | | | | | |-- a-regular
| | | | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | | | |-- dir-symlink -> subdir-l13
| | | | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | | | |-- subdir-l13
| | | | | | | | | | | | | |-- A-regular
| | | | | | | | | | | | | |-- Z-regular
| | | | | | | | | | | | | |-- a-regular
| | | | | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | | | | |-- dir-symlink -> subdir-l14
| | | | | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | | | | |-- subdir-l14
| | | | | | | | | | | | | | |-- A-regular
| | | | | | | | | | | | | | |-- Z-regular
| | | | | | | | | | | | | | |-- a-regular
| | | | | | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | | | | | |-- dir-symlink -> subdir-l15
| | | | | | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | | | | | |-- subdir-l15
| | | | | | | | | | | | | | | |-- A-regular
| | | | | | | | | | | | | | | |-- Z-regular
| | | | | | | | | | | | | | | |-- a-regular
| | | | | | | | | | | | | | | |-- danglging-symlink -> invalid
| | | | | | | | | | | | | | | |-- dir-symlink -> subdir-l16
| | | | | | | | | | | | | | | |-- parent-dir-symlink -> ..
| | | | | | | | | | | | | | | |-- root-dir-symlink -> /
| | | | | | | | | | | | | | | |-- subdir-l16
| | | | | | | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | | | | | | `-- z-regular
| | | | | | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | | | | | `-- z-regular
| | | | | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | | | | `-- z-regular
| | | | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | | | `-- z-regular
| | | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | | `-- z-regular
| | | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | | `-- z-regular
| | | | | | | | | |-- symlink -> a-regular
| | | | | | | | | `-- z-regular
| | | | | | | | |-- symlink -> a-regular
| | | | | | | | `-- z-regular
| | | | | | | |-- symlink -> a-regular
| | | | | | | `-- z-regular
| | | | | | |-- symlink -> a-regular
| | | | | | `-- z-regular
| | | | | |-- symlink -> a-regular
| | | | | `-- z-regular
| | | | |-- symlink -> a-regular
| | | | `-- z-regular
| | | |-- symlink -> a-regular
| | | `-- z-regular
| | |-- symlink -> a-regular
| | `-- z-regular
| |-- symlink -> a-regular
| `-- z-regular
|-- symlink -> a-regular
`-- z-regular
65 directories, 96 files

View File

@ -1,3 +1,12 @@
From 061d7800ccad941b6a2f4cb230412097872fa457 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 22 Dec 2021 10:10:38 +0100
Subject: [PATCH] Resolves: #948991 - document --du and --prune options
... in help output
Sent upstream via email 20210920
---
tree.c | 2 ++ tree.c | 2 ++
1 file changed, 2 insertions(+) 1 file changed, 2 insertions(+)
@ -5,12 +14,15 @@ diff --git a/tree.c b/tree.c
index 5b56afe..3b4a263 100644 index 5b56afe..3b4a263 100644
--- a/tree.c --- a/tree.c
+++ b/tree.c +++ b/tree.c
@@ -653,6 +653,8 @@ void usage(int n) @@ -610,6 +610,8 @@ void usage(int n)
" --charset X Use charset X for terminal/HTML and indentation line output.\n"
" --filelimit # Do not descend dirs with more than # files in them.\n" " --filelimit # Do not descend dirs with more than # files in them.\n"
" --timefmt <f> Print and format time according to the format <f>.\n"
" -o filename Output to file instead of stdout.\n" " -o filename Output to file instead of stdout.\n"
+ " --du Print directory sizes.\n" + " --du Print directory sizes.\n"
+ " --prune Prune empty directories from the output.\n" + " --prune Prune empty directories from the output.\n"
" ------- File options -------\n" " ------- File options -------\n"
" -q Print non-printable characters as '?'.\n" " -q Print non-printable characters as '?'.\n"
" -N Print non-printable characters as is.\n" " -N Print non-printable characters as is.\n"
--
2.31.1

View File

@ -1,13 +1,14 @@
Summary: File system tree viewer Summary: File system tree viewer
Name: tree-pkg Name: tree-pkg
Version: 1.8.0 Version: 2.1.0
Release: 10%{?dist} Release: 8%{?dist}
# The entire source code is GPLv2+ except strverscmp.c which is LGPLv2+ # The entire source code is LGPL-2.1-or-later except strverscmp.c
License: GPLv2+ and LGPLv2+ # which is LGPL-2.1-or-later.
License: GPL-2.0-or-later AND LGPL-2.1-or-later
URL: http://mama.indstate.edu/users/ice/tree/ URL: https://mama.indstate.edu/users/ice/tree/
Source: ftp://mama.indstate.edu/linux/tree/tree-%{version}.tgz Source: https://mama.indstate.edu/users/ice/tree/src/tree-%{version}.tgz
BuildRequires: gcc BuildRequires: gcc
BuildRequires: make BuildRequires: make
@ -16,18 +17,10 @@ BuildRequires: make
# Sent upstream via email 20210920 # Sent upstream via email 20210920
Patch0: tree-license-fsf-addr.patch Patch0: tree-license-fsf-addr.patch
# Preserve timestamp on man page.
# Sent upstream via email 20210920
Patch2: tree-preserve-timestamps.patch
# Document --du and --prune options in help output (bug #948991). # Document --du and --prune options in help output (bug #948991).
# Sent upstream via email 20210920 # Sent upstream via email 20210920
Patch4: tree-args.patch Patch4: tree-args.patch
# Use correct default for dircolors "ec" field (bug #812934).
# Sent upstream via email 20210920
Patch6: tree-dircolors-ec.patch
# Keep file size field length constant regardless of whether SI units # Keep file size field length constant regardless of whether SI units
# are used (bug #997937). # are used (bug #997937).
# Sent upstream via email 20210920 # Sent upstream via email 20210920
@ -37,6 +30,10 @@ Patch7: tree-size-field-len.patch
# Sent upstream via email 20181106 # Sent upstream via email 20181106
Patch8: tree-static-analysis.patch Patch8: tree-static-analysis.patch
# fix programming mistakes detected by static analysis (RHEL-36490)
# Upstream is not active
Patch9: tree-static-analysis-2.patch
%description %description
The source RPM package of tree, which has to be named differently due to The source RPM package of tree, which has to be named differently due to
limitations of Pagure and Gitlab. limitations of Pagure and Gitlab.
@ -57,15 +54,11 @@ sed -e 's/LINUX/__linux__/' -i tree.c
%build %build
%set_build_flags %set_build_flags
%make_build CFLAGS="$RPM_OPT_FLAGS $(getconf LFS_CFLAGS)" %make_build CFLAGS="$RPM_OPT_FLAGS $(getconf LFS_CFLAGS)" LDFLAGS="$LDFLAGS"
%install %install
mkdir -p $RPM_BUILD_ROOT%{_bindir} %make_install DESTDIR=$RPM_BUILD_ROOT%{_bindir} \
MANDIR=$RPM_BUILD_ROOT%{_mandir}
%make_install BINDIR=$RPM_BUILD_ROOT%{_bindir} \
MANDIR=$RPM_BUILD_ROOT%{_mandir}/man1
chmod -x $RPM_BUILD_ROOT%{_mandir}/man1/tree.1
%files -n tree %files -n tree
%{_bindir}/tree %{_bindir}/tree
@ -74,7 +67,51 @@ chmod -x $RPM_BUILD_ROOT%{_mandir}/man1/tree.1
%doc README %doc README
%changelog %changelog
* Fri Sep 17 2021 Kamil Dudka <kdudka@redhat.com> - 1.8.0-10 * Mon Nov 04 2024 Vincent Mihalkovic <vmihalko@redhat.com> - 2.1.0-8
- fix programming mistakes detected by static analysis
Resolves: RHEL-36490
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 2.1.0-7
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 2.1.0-6
- Bump release for June 2024 mass rebuild
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Jun 01 2023 Lukáš Zaoral <lzaoral@redhat.com> - 2.1.0-3
- migrate to SPDX license format
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Wed Dec 28 2022 Kamil Dudka <kdudka@redhat.com> - 2.1.0-1
- update to the latest upstream release
* Wed Sep 07 2022 Kamil Dudka <kdudka@redhat.com> - 2.0.4-1
- update to the latest upstream release
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Thu Jun 09 2022 Kamil Dudka <kdudka@redhat.com> - 2.0.2-1
- update to the latest upstream release (#2094897)
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Mon Jan 17 2022 Kamil Dudka <kdudka@redhat.com> - 2.0.1-1
- update to the latest upstream release
* Wed Dec 22 2021 Kamil Dudka <kdudka@redhat.com> - 2.0.0-1
- update to the latest upstream release
* Fri Sep 17 2021 Kamil Dudka <kdudka@redhat.com> - 1.8.0-9
- reflect review comments from Fedora Review (#2001467) - reflect review comments from Fedora Review (#2001467)
* Fri Sep 03 2021 Kamil Dudka <kdudka@redhat.com> - 1.8.0-8 * Fri Sep 03 2021 Kamil Dudka <kdudka@redhat.com> - 1.8.0-8

View File

@ -0,0 +1,56 @@
From b25def5b8385f8382d3da1e37fc2204ffedc72e5 Mon Sep 17 00:00:00 2001
From: Vincent Mihalkovic <vmihalko@redhat.com>
Date: Thu, 31 Oct 2024 14:56:32 +0100
Subject: [PATCH] json, xml: fix identical branches warning
Error: IDENTICAL_BRANCHES (CWE-398):
tree-2.1.0/json.c:124: identical_branches: The same code is executed regardless of whether "file->lnk" is true, because the 'then' and 'else' branches are identical. Should one of the branches be modified, or the entire 'if' statement replaced?
122|
123| if (file != NULL) {
124|-> if (file->lnk) mt = file->mode & S_IFMT;
125| else mt = file->mode & S_IFMT;
126| } else mt = 0;
Error: IDENTICAL_BRANCHES (CWE-398):
tree-2.1.0/json.c:124: identical_branches: The same code is executed regardless of whether "file->lnk" is true, because the 'then' and 'else' branches are identical. Should one of the branches be modified, or the entire 'if' statement replaced?
122|
123| if (file != NULL) {
124|-> if (file->lnk) mt = file->mode & S_IFMT;
125| else mt = file->mode & S_IFMT;
126| } else mt = 0;
---
json.c | 3 +--
xml.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/json.c b/json.c
index 3495448..e86a590 100644
--- a/json.c
+++ b/json.c
@@ -121,8 +121,7 @@ int json_printinfo(char *dirname, struct _info *file, int level)
if (!noindent) json_indent(level);
if (file != NULL) {
- if (file->lnk) mt = file->mode & S_IFMT;
- else mt = file->mode & S_IFMT;
+ mt = file->mode & S_IFMT;
} else mt = 0;
for(t=0;ifmt[t];t++)
diff --git a/xml.c b/xml.c
index 9fdf74e..96c76f2 100644
--- a/xml.c
+++ b/xml.c
@@ -105,8 +105,7 @@ int xml_printinfo(char *dirname, struct _info *file, int level)
if (!noindent) xml_indent(level);
if (file != NULL) {
- if (file->lnk) mt = file->mode & S_IFMT;
- else mt = file->mode & S_IFMT;
+ mt = file->mode & S_IFMT;
} else mt = 0;
for(t=0;ifmt[t];t++)
--
2.46.2

View File

@ -0,0 +1,39 @@
From 48641275c0cd018441685f2d3145038017f1ea42 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Tue, 6 Nov 2018 16:31:32 +0100
Subject: [PATCH] tree: fix programming mistakes detected by static analysis
---
list.c | 2 +-
tree.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/list.c b/list.c
index 36cfbe5..c490dec 100644
--- a/list.c
+++ b/list.c
@@ -43,7 +43,7 @@ void emit_tree(char **dirname, bool needfulltree)
struct ignorefile *ig = NULL;
struct infofile *inf = NULL;
struct _info **dir = NULL, *info = NULL;
- char *err;
+ char *err = NULL;
int i, j, n, needsclosed;
struct stat st;
diff --git a/tree.c b/tree.c
index 0d51281..94aed2c 100644
--- a/tree.c
+++ b/tree.c
@@ -917,7 +917,7 @@ struct _info **unix_getfulltree(char *d, u_long lev, dev_t dev, off_t *size, cha
if (*(*dir)->lnk == '/')
(*dir)->child = unix_getfulltree((*dir)->lnk,lev+1,dev,&((*dir)->size),&((*dir)->err));
else {
- if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->name)+1024));
+ if (strlen(d)+strlen((*dir)->lnk)+2 > pathsize) path=xrealloc(path,pathsize=(strlen(d)+strlen((*dir)->lnk)+1024));
if (fflag && !strcmp(d,"/")) sprintf(path,"%s%s",d,(*dir)->lnk);
else sprintf(path,"%s/%s",d,(*dir)->lnk);
(*dir)->child = unix_getfulltree(path,lev+1,dev,&((*dir)->size),&((*dir)->err));
--
2.17.2