From 13fe9f7f820d43400912b56aa6745a2b8007a514 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sun, 20 Jan 2019 19:47:33 +0000 Subject: [PATCH] Fix crash in systat(4) when certain commands are called without arguments Add check for missing arguments to dsmatchselect and dsselect PR: 219689 Submitted by: Marko Turk MFC after: 1 week --- usr.bin/systat/devs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c index e6b1e48eb10e..e1c12eacbe74 100644 --- a/usr.bin/systat/devs.c +++ b/usr.bin/systat/devs.c @@ -193,6 +193,11 @@ dsmatchselect(const char *args, devstat_select_mode select_mode, int maxshowdevs int i; int retval = 0; + if (!args) { + warnx("dsmatchselect: no arguments"); + return(0); + } + /* * Break the (pipe delimited) input string out into separate * strings. @@ -251,6 +256,11 @@ dsselect(const char *args, devstat_select_mode select_mode, int maxshowdevs, int i; int retval = 0; + if (!args) { + warnx("dsselect: no argument"); + return(1); + } + /* * If we've gone through this code before, free previously * allocated resources.