]> granicus.if.org Git - procps-ng/commitdiff
free,slabtop,uptime: complain about extra ops
authorCraig Small <csmall@dropbear.xyz>
Mon, 19 Oct 2020 11:36:06 +0000 (22:36 +1100)
committerCraig Small <csmall@dropbear.xyz>
Mon, 19 Oct 2020 11:41:54 +0000 (22:41 +1100)
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
free.c
slabtop.c
uptime.c

diff --git a/NEWS b/NEWS
index 57790af5db187605c4fcc5c86452e210b1d4723f..b3cda2c34b14f39216d2b8577962c8a2ac1d1ee9 100644 (file)
--- 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 6a07504198f60b8bf4b8b02009836f393f5ce8af..5fb3d7d335791f6140ea0c6acc0bb19468d8f7f7 100644 (file)
--- a/free.c
+++ b/free.c
@@ -342,6 +342,8 @@ int main(int argc, char **argv)
                default:
                        usage(stderr);
                }
+       if (optind != argc)
+           usage(stderr);
 
        if (procps_meminfo_new(&mem_info) < 0)
            xerrx(EXIT_FAILURE,
index 9966af1e1b77a080f8e61ec6752e7b5d21f8c15a..64a52da098e295b1d4584f4f403a665a738e40d9 100644 (file)
--- a/slabtop.c
+++ b/slabtop.c
@@ -202,6 +202,8 @@ static void parse_opts (int argc, char **argv)
             usage(stderr);
         }
     }
+    if (optind != argc)
+        usage(stderr);
 }
 
 static void print_summary (void)
index 2fdef8493e36eb538f57a5b0d86dbcadafb52a95..c5eaa3e7ea757db8a5b903efe30fa1489f34c920 100644 (file)
--- a/uptime.c
+++ b/uptime.c
@@ -106,6 +106,9 @@ int main(int argc, char **argv)
             usage(stderr);
         }
 
+    if (optind != argc)
+        usage(stderr);
+
     if (p)
         printf("%s\n", procps_uptime_sprint_short());
     else