From 959be708f4618c49737ab1609bbde27702fb63ba Mon Sep 17 00:00:00 2001 From: Jan Rybar Date: Nov 14 2023 16:28:27 +0000 Subject: pgrep complains wrongly about long match over 15 characters Resolves: bz#2249615 --- diff --git a/pgrep-regex-warning.patch b/pgrep-regex-warning.patch new file mode 100644 index 0000000..f8846ec --- /dev/null +++ b/pgrep-regex-warning.patch @@ -0,0 +1,62 @@ +commit cfb3c482a5c9235a9899e107f2f90873164f7049 +Author: Craig Small +Date: Tue Jun 13 16:23:35 2023 +1000 + + pgrep: Suppress warning if using regex + + pgrep gives a warning if the match string is longer than + 15 characters and there was no match. That often does not + make sense when using regex or at the very least difficult + to know when to warn users. e.g + "1234567890|123456789X" is a 21 character string but only + matching two 10 string words. + + pgrep has a simple check for regex and will now suppress + that warning if that has been used. + + References: + https://bugs.debian.org/1037450 + + Signed-off-by: Craig Small + +diff --git a/src/pgrep.c b/src/pgrep.c +index 442dbfcc..838bb2d0 100644 +--- a/src/pgrep.c ++++ b/src/pgrep.c +@@ -636,6 +636,27 @@ static size_t get_arg_max(void) + return val; + } + ++/* ++ * Check if we have a long simple (non-regex) match ++ * Returns true if the string: ++ * 1) is longer than 15 characters ++ * 2) Doesn't have | or [ which are used by regex ++ * This is not an exhaustive list but catches most instances ++ * It's only used to suppress the warning ++ */ ++static bool is_long_match(const char *str) ++{ ++ int i, len; ++ ++ if (str == NULL) ++ return FALSE; ++ if (15 >= (len = strlen(str))) ++ return FALSE; ++ for (i=0; i 15)) ++ if ((!matches) && (!opt_full) && is_long_match(opt_pattern)) + xwarnx(_("pattern that searches for process name longer than 15 characters will result in zero matches\n" + "Try `%s -f' option to match against the complete command line."), + program_invocation_short_name); diff --git a/procps-ng.spec b/procps-ng.spec index 12ed788..88457dd 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -4,7 +4,7 @@ Summary: System and process monitoring utilities Name: procps-ng Version: 4.0.3 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -12,6 +12,7 @@ Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz Patch1: sysctl-nameonly-shows-value.patch Patch2: cve-2023-4016.patch +Patch3: pgrep-regex-warning.patch BuildRequires: make BuildRequires: ncurses-devel @@ -148,6 +149,10 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %files i18n -f %{name}.lang %changelog +* Tue Nov 14 2023 Jan Rybar - 4.0.3-4 +- pgrep complains wrongly about long match over 15 characters +- Resolves: bz#2249615 + * Mon Aug 14 2023 Jan Rybar - 4.0.3-4 - CVE-2023-4016: ps: buffer overflow - Resolves: bz#2230186