Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 May 2024 17:14:17 GMT
From:      Piotr Pawel Stefaniak <pstef@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3f0b80bc1537 - main - ps: handle incorrect -D values
Message-ID:  <202405061714.446HEHnL024098@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by pstef:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f0b80bc1537c257f3bd68592832ec8cb65e1c58

commit 3f0b80bc1537c257f3bd68592832ec8cb65e1c58
Author:     Jamie Landeg-Jones <jamie@catflap.org>
AuthorDate: 2024-04-23 16:44:36 +0000
Commit:     Piotr Paweł Stefaniak <pstef@FreeBSD.org>
CommitDate: 2024-05-06 17:13:35 +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.
---
 bin/ps/ps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index cbee10c20d53..53ace6247b33 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -263,6 +263,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?202405061714.446HEHnL024098>