Created attachment 183110 [details] patch Hi, some combinations of invalid arguments can crash systat. For example: systat -vmstat -d Segmentation fault (core dumped) I've attached a patch that fixes this. (gdb) bt #0 strlen (str=0x0) at /usr/src/lib/libc/string/strlen.c:100 #1 0x0000000801170092 in strdup (str=0x0) at /usr/src/lib/libc/string/strdup.c:46 #2 0x0000000000403c12 in dsselect (args=0x0, select_mode=DS_SELECT_ADDONLY, maxshowdevs=7, s1=0x621e00) at /usr/src/usr.bin/systat/devs.c:267 #3 0x000000000040ff4e in cmdkre (cmd=<value optimized out>, args=0x0) at _ctype.h:107 #4 0x0000000000405955 in main (argc=<value optimized out>, argv=<value optimized out>) at /usr/src/usr.bin/systat/main.c:225 #5 0x0000000000402f1f in _start () #6 0x000000080063a000 in ?? () #7 0x0000000000000000 in ?? () /Marko
Confirmed reproducible on 12-current r321400
A commit references this bug: Author: gonzo Date: Sun Jan 20 19:47:34 UTC 2019 New revision: 343222 URL: https://svnweb.freebsd.org/changeset/base/343222 Log: 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 <mt@markoturk.info> MFC after: 1 week Changes: head/usr.bin/systat/devs.c
A commit references this bug: Author: gonzo Date: Sun Jan 20 19:55:54 UTC 2019 New revision: 343223 URL: https://svnweb.freebsd.org/changeset/base/343223 Log: Fix inconsistency in return values introduced by r343222 Consistently return 1 or the case of missing arguments in both functions PR: 219689 MFC after: 1 week X-MFC-With: 343222 Changes: head/usr.bin/systat/devs.c
Patch has bin committed, thanks for submitting it. I'll handle MFC in a week.
A commit references this bug: Author: gonzo Date: Sun Feb 3 14:47:22 UTC 2019 New revision: 343714 URL: https://svnweb.freebsd.org/changeset/base/343714 Log: MFC r343222-r343223, r343338 r343222: 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 <mt@markoturk.info> r343223: Fix inconsistency in return values introduced by r343222 Consistently return 1 or the case of missing arguments in both functions PR: 219689 X-MFC-With: 343222 r343338: Fix systat's :only command parser for the multiple arguments case According to systat(1) :only option is supposed to accept multiple drives but the parser for its arguments stops after first entry. Fix the parser logic to accept multiple drives. PR: 59220 Reported by: Andy Farkas <andyf@speednet.com.au> Changes: _U stable/12/ stable/12/usr.bin/systat/devs.c
A commit references this bug: Author: gonzo Date: Sun Feb 3 14:47:23 UTC 2019 New revision: 343714 URL: https://svnweb.freebsd.org/changeset/base/343714 Log: MFC r343222-r343223, r343338 r343222: 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 <mt@markoturk.info> r343223: Fix inconsistency in return values introduced by r343222 Consistently return 1 or the case of missing arguments in both functions PR: 219689 X-MFC-With: 343222 r343338: Fix systat's :only command parser for the multiple arguments case According to systat(1) :only option is supposed to accept multiple drives but the parser for its arguments stops after first entry. Fix the parser logic to accept multiple drives. PR: 59220 Reported by: Andy Farkas <andyf@speednet.com.au> Changes: _U stable/12/ stable/12/usr.bin/systat/devs.c