Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 May 2025 19:51:22 GMT
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 93ef18f9e83b - stable/14 - ps: handle incorrect -D values
Message-ID:  <202505011951.541JpMjf067001@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=93ef18f9e83b15cfa3d844d9624462703caee381

commit 93ef18f9e83b15cfa3d844d9624462703caee381
Author:     Jamie Landeg-Jones <jamie@catflap.org>
AuthorDate: 2024-04-23 16:44:36 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-05-01 19:35:07 +0000

    ps: handle incorrect -D values
    
    I just noticed a slight issue with the '-D' option. Basically,
    I accidentally typed something along the lines of:
    
    ps -Dboth-p303
    
    I.E. missing out the "space". Instead of giving an error, it behaved as
    if I'd just typed "ps".
    
    Looking at bin/ps/ps.c, where the -D option is parsed, it doesn't
    error-out if there is no valid match.
    
    This commit fixes the bug.
    
    (cherry picked from commit 3f0b80bc1537c257f3bd68592832ec8cb65e1c58)
---
 bin/ps/ps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 16d8a0a58d3c..897b4ccd9a92 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -276,6 +276,8 @@ main(int argc, char *argv[])
 				else if (len <= 4 &&
 					strncasecmp(optarg, "both", len) == 0)
 					directions |= BOTH;
+				else
+					usage();
 				break;
 			}
 		case 'd':



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505011951.541JpMjf067001>