From cb134481791aadbbbf548b5bb3996f174b543e65 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Mon, 19 Oct 2020 22:36:06 +1100 Subject: [PATCH] free,slabtop,uptime: complain about extra ops free, slabtop and uptime would happily take extra command line arguments and doing nothing about them. The programs now check optind after option processing and will give you usage screen if there is anything extra. References: procps-ng/procps#181 --- NEWS | 1 + free.c | 2 ++ slabtop.c | 3 +++ uptime.c | 3 +++ 4 files changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 89df56f6..ea45942e 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ procps-ng NEXT * vmstat: Wide mode gives wider proc columns merge #48 * watch: Add environment variable for interval merge #62 * watch: Add no linewrap option issue #182 + * free,uptime,slabtop: complain about extra ops issue #181 procps-ng-3.3.16 ---------------- diff --git a/free.c b/free.c index f82546eb..ac706472 100644 --- a/free.c +++ b/free.c @@ -341,6 +341,8 @@ int main(int argc, char **argv) default: usage(stderr); } + if (optind != argc) + usage(stderr); do { diff --git a/slabtop.c b/slabtop.c index b7b0647b..2ffe992f 100644 --- a/slabtop.c +++ b/slabtop.c @@ -341,6 +341,9 @@ int main(int argc, char *argv[]) } } + if (optind != argc) + usage(stderr); + is_tty = isatty(STDIN_FILENO); if (is_tty && tcgetattr(STDIN_FILENO, &saved_tty) == -1) xwarn(_("terminal setting retrieval")); diff --git a/uptime.c b/uptime.c index 4db15f77..8ea2d683 100644 --- a/uptime.c +++ b/uptime.c @@ -107,6 +107,9 @@ int main(int argc, char **argv) usage(stderr); } + if (optind != argc) + usage(stderr); + print_uptime(p); return EXIT_SUCCESS; }