Compare commits

..

No commits in common. "7020426af3240e7fde67bbbfb82b50f8e74e0fe9" and "7a2c4050d109929872e71a9cc206164e7ec7c044" have entirely different histories.

3 changed files with 3 additions and 171 deletions

View File

@ -1,59 +0,0 @@
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

@ -1,72 +0,0 @@
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: 10
Release: 5
Summary: A tool for list open files
License: zlib and Sendmail and LGPLv2+
URL: https://people.freebsd.org/~abe/
@ -9,8 +9,6 @@ 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
@ -32,20 +30,12 @@ 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.1 %{buildroot}/%{_mandir}/man1/lsof.1
%check
pushd tests
chmod u+w TestDB
./Add2TestDB
make test %{?_smp_mflags} DEBUG="%{optflags} -Wall -Wno-unused"
popd
install -p -m 0644 Lsof.8 %{buildroot}/%{_mandir}/man1/lsof.1
%files
%doc 00CREDITS
@ -56,34 +46,7 @@ popd
%{_mandir}/man*/*
%changelog
* 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
* Wed Feb 10 2020 chenjialong<chenjialong@huawei.com> - 4.93.2-5
- Type:NA
- ID:NA
- SUG:NA