Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
7020426af3
!42 同步上游社区补丁
From: @dongyuzhen 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2023-06-14 08:22:46 +00:00
dongyuzhen
95a47886af backport upstream patches 2023-06-14 15:31:21 +08:00
openeuler-ci-bot
d71ba7b6ea
!33 enable make check
From: @hubin95 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
2023-02-16 03:59:00 +00:00
hubin
d2b392ee32 enable make check
Signed-off-by: hubin <hubin73@huawei.com>
2023-02-16 11:36:07 +08:00
openeuler-ci-bot
45b1203e19
!31 fix the date error in changelog
From: @dongyuzhen 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2022-11-16 09:55:07 +00:00
dongyuzhen
a7f83c3a8f fix the date error in changelog 2022-11-16 17:19:34 +08:00
openeuler-ci-bot
315efca979
!28 fix valgrind error write to uninitialized bytes
From: @hubin95 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
2022-11-16 08:59:39 +00:00
hubin
892ba6e0f5 fix valgrind error write to uninitialized bytes
Signed-off-by: hubin <hubin73@huawei.com>
2022-11-15 19:36:04 +08:00
openeuler-ci-bot
381af72141
!22 修复“man lsof”显示的openssl-version帮助页的问题
From: @yue-yuankun 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
2022-11-15 08:44:06 +00:00
yueyuankun
50d54f1208 Fix "man lsof" content error 2022-08-24 11:25:09 +08:00
3 changed files with 171 additions and 3 deletions

View File

@ -0,0 +1,59 @@
From b14d947b3548df94456dd9831d5f969403daf9e4 Mon Sep 17 00:00:00 2001
From: Masatake YAMATO <yamato@redhat.com>
Date: Tue, 24 Dec 2019 21:26:26 +0900
Subject: [PATCH] Fill the buffer using pipe communication with zero
Lsof runs sub processes for implementing non-blocking
stat, lstat, and readlink. Lsof main process uses pipes fo
for coummunicating with the sub processes.
Valgrind reports a buffer used in the pipe communication
isn't initialized:
$ sudo valgrind -v --track-origins=yes ./lsof > /dev/null
==13857== Memcheck, a memory error detector
==13857== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13857== Using Valgrind-3.14.0-353a3587bb-20181007X and LibVEX; rerun with -h for copyright info
==13857== Command: ./lsof
...
==13858== Rerun with --leak-check=full to see details of leaked memory
==13858==
==13858== ERROR SUMMARY: 199 errors from 1 contexts (suppressed: 0 from 0)
==13858==
==13858== 199 errors in context 1 of 1:
==13858== Syscall param write(buf) points to uninitialised byte(s)
==13858== at 0x5380E34: write (write.c:27)
==13858== by 0x41E477: doinchild (misc.c:369)
==13858== by 0x41FB11: Readlink (misc.c:1108)
==13858== by 0x403FBD: readmnt (dmnt.c:512)
==13858== by 0x4071D9: initialize (dproc.c:655)
==13858== by 0x41C99D: main (main.c:1253)
==13858== Address 0x1ffeff9e60 is on thread 1's stack
==13858== in frame #1, created by doinchild (misc.c:247)
==13858== Uninitialised value was created by a stack allocation
==13858== at 0x41E149: doinchild (misc.c:247)
==13858==
==13858== ERROR SUMMARY: 199 errors from 1 contexts (suppressed: 0 from 0)
The code causing the erros seems harmless. However, keeping the output
of valgrind clean may be good for continuing maintaining lsof.
No update for 00DIST because this change is invisble to users.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
misc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/misc.c b/misc.c
index be051609..3bebdc58 100644
--- a/misc.c
+++ b/misc.c
@@ -360,6 +360,7 @@ doinchild(fn, fp, rbuf, rbln)
!= (int)sizeof(r_rbln)
|| r_rbln < 1 || r_rbln > (int)sizeof(r_rbuf))
break;
+ zeromem (r_rbuf, r_rbln);
rv = r_fn(r_arg, r_rbuf, r_rbln);
en = errno;
if (write(Pipes[3], (char *)&rv, sizeof(rv))

View File

@ -0,0 +1,72 @@
From 19c6e483982456b9cf78c87b9cf3c90e98d63024 Mon Sep 17 00:00:00 2001
From: Masatake YAMATO <yamato@redhat.com>
Date: Sun, 23 Apr 2023 14:48:46 +0800
Subject: [PATCH] backport fix Fo option
-Fo option is for printing file offset. For regular files,
the option didn't work.
Here is a command session demonstrating the fix:
# ./lsof -Fo -o0| grep ^o | sort | uniq -c
90586 o0t0
87 o0t101
84 o0t103
...
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Reference:https://github.com/lsof-org/lsof/commit/6435e7667cbf5b1a616606aa019892df43f3ade1
Conflict:NA
---
main.c | 4 ++++
tests/case-20-offset-field.bash | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 tests/case-20-offset-field.bash
diff --git a/main.c b/main.c
index 169e334..9e3bbd8 100644
--- a/main.c
+++ b/main.c
@@ -554,6 +554,10 @@ main(argc, argv)
if (i == LSOF_FIX_TERM)
Terminator = '\0';
+
+ if (i == LSOF_FIX_OFFSET)
+ Foffset = 1;
+
break;
}
}
diff --git a/tests/case-20-offset-field.bash b/tests/case-20-offset-field.bash
new file mode 100644
index 0000000..a5dc369
--- /dev/null
+++ b/tests/case-20-offset-field.bash
@@ -0,0 +1,24 @@
+name=$(basename $0 .bash)
+lsof=$1
+report=$2
+base=$(pwd)
+
+t=/tmp/lsof-test-reg-file-$$
+p=/tmp/lsof-test-reg-fifo-$$
+
+mkfifo $p
+{
+ printf "%d" 1
+ read < $p &
+} | cat > $t &
+
+r=1
+if [ "$($lsof -Fo $t | grep '^o')" = o0t1 ]; then
+ echo > $p
+ r=0
+fi
+
+rm /tmp/lsof-test-reg-file-$$
+rm /tmp/lsof-test-reg-fifo-$$
+
+exit $r
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: lsof
Version: 4.93.2
Release: 5
Release: 10
Summary: A tool for list open files
License: zlib and Sendmail and LGPLv2+
URL: https://people.freebsd.org/~abe/
@ -9,6 +9,8 @@ Patch0: 0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch
Patch1: 0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch
Patch2: 0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch
Patch3: Handle-ffff-ffff-in-ipv6-addr-correctly.patch
Patch4: backport-Fill-the-buffer-using-pipe-communication-with-zero.patch
Patch5: backport-fix-Fo-option.patch
BuildRequires: gcc git libtirpc-devel libselinux-devel
@ -30,12 +32,20 @@ The %{name}-help package contains doc files for %{name}.
%build
./Configure -n linux
%make_build DEBUG="%{build_cflags} -I/usr/include/tirpc" CFGL="%{build_ldflags} -L./lib -llsof -lselinux -ltirpc"
soelim -r Lsof.8 > lsof.1
%install
mkdir -p %{buildroot}/%{_bindir}
install -p -m 0755 lsof %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/%{_mandir}/man1
install -p -m 0644 Lsof.8 %{buildroot}/%{_mandir}/man1/lsof.1
install -p -m 0644 lsof.1 %{buildroot}/%{_mandir}/man1/lsof.1
%check
pushd tests
chmod u+w TestDB
./Add2TestDB
make test %{?_smp_mflags} DEBUG="%{optflags} -Wall -Wno-unused"
popd
%files
%doc 00CREDITS
@ -46,7 +56,34 @@ install -p -m 0644 Lsof.8 %{buildroot}/%{_mandir}/man1/lsof.1
%{_mandir}/man*/*
%changelog
* Wed Feb 10 2020 chenjialong<chenjialong@huawei.com> - 4.93.2-5
* Wed Jun 14 2023 dongyuzhen <dongyuzhen@h-partners.com> - 4.93.2-10
- backport upstream patches
* Thu Feb 16 2023 hubin <hubin73@huawei.com> - 4.93.2-9
- Type:testcode
- ID:NA
- SUG:NA
- DESC:enable make check
* Wed Nov 16 2022 dongyuzhen <dongyuzhen@h-partners.com> - 4.93.2-8
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the date error in changelog
* Tue Nov 15 2022 Bin Hu <hubin73@huawei.com> - 4.93.2-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix valgrind error write to uninitialized bytes
* Wed Aug 24 2022 yueyuankun <yueyuankun@kylinos.cn> - 4.93.2-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Fix "man lsof" content error
* Wed Feb 10 2021 chenjialong <chenjialong@huawei.com> - 4.93.2-5
- Type:NA
- ID:NA
- SUG:NA