[packages/lsof] Rel 2. Fix -s UDP:ESTABLISHED segfault, link with rpmldflags
arekm
arekm at pld-linux.org
Thu Oct 29 08:44:51 CET 2026
commit f255fb056195455ac45b75e26726c5d316443396
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 00:12:48 2026 +0100
Rel 2. Fix -s UDP:ESTABLISHED segfault, link with rpmldflags
lsof-state-spec-null.patch | 36 ++++++++++++++++++++++++++++++++++++
lsof.spec | 4 ++++
2 files changed, 40 insertions(+)
---
diff --git a/lsof.spec b/lsof.spec
index 25d341b..6a17996 100644
--- a/lsof.spec
+++ b/lsof.spec
@@ -11,6 +11,8 @@ License: Free
Group: Applications/System
Source0: https://github.com/lsof-org/lsof/archive/%{version}/lsof-%{version}.tar.gz
# Source0-md5: 6d2dd9e9986b016ec79f3698353230bc
+# https://github.com/lsof-org/lsof/commit/abd5ba48bc03e07d0a4b186e3486b44d3982d652
+Patch0: %{name}-state-spec-null.patch
URL: https://people.freebsd.org/~abe/
BuildRequires: libselinux-devel
BuildRequires: libtirpc-devel
@@ -48,9 +50,11 @@ Lsof - це скорочення від LiSt Open Files. Саме це прог
%prep
%setup -q
+%patch -P0 -p1
%build
LSOF_CC="%{__cc}"; export LSOF_CC
+LSOF_CFGL="%{rpmldflags}"; export LSOF_CFGL
./Configure -n linux
%{__make} \
DEBUG="%{rpmcppflags} %{rpmcflags}"
diff --git a/lsof-state-spec-null.patch b/lsof-state-spec-null.patch
new file mode 100644
index 0000000..f8d9cc3
--- /dev/null
+++ b/lsof-state-spec-null.patch
@@ -0,0 +1,36 @@
+From abd5ba48bc03e07d0a4b186e3486b44d3982d652 Mon Sep 17 00:00:00 2001
+From: Jiajie Chen <c at jia.je>
+Date: Fri, 24 Jul 2026 08:46:34 +0800
+Subject: [PATCH] fix: segfault in -s UDP:ESTABLISHED due to NULL UdpSt entries
+
+UdpSt[] and TcpSt[] arrays may contain NULL entries when state numbers
+don't start at 0. The matching loop in enter_state_spec passed entries
+directly to strcasecmp without NULL-checking, causing a segfault.
+
+Add NULL guards before strcasecmp calls.
+---
+ src/arg.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/arg.c b/src/arg.c
+index 9560f42a..750ab690 100644
+--- a/src/arg.c
++++ b/src/arg.c
+@@ -1861,7 +1861,7 @@ int enter_state_spec(struct lsof_context *ctx,
+ if (tx) {
+ if (UdpSt) {
+ for (i = 0; i < UdpNstates; i++) {
+- if (!strcasecmp(ns, UdpSt[i])) {
++ if (UdpSt[i] && !strcasecmp(ns, UdpSt[i])) {
+ f = 1;
+ break;
+ }
+@@ -1870,7 +1870,7 @@ int enter_state_spec(struct lsof_context *ctx,
+ } else {
+ if (TcpSt) {
+ for (i = 0; i < TcpNstates; i++) {
+- if (!strcasecmp(ns, TcpSt[i])) {
++ if (TcpSt[i] && !strcasecmp(ns, TcpSt[i])) {
+ f = 1;
+ break;
+ }
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/lsof.git/commitdiff/f255fb056195455ac45b75e26726c5d316443396
More information about the pld-cvs-commit
mailing list