From 61ef814f56d255117bdc797f73d8b9da5b54ad59 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Fri, 18 Jan 2019 23:26:31 +0000 Subject: [PATCH] Fix top(1) long options handling getopt_long(3) requires the long options be terminated by a NULL block. Without the terminator, an invalid long option results in a segmentation fault. Reported by: Brandon Bergren MFC after: 1 week --- usr.bin/top/top.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index a4bdb5013861..80fa446fc7b1 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -110,7 +110,8 @@ static const struct option longopts[] = { { "uids", no_argument, NULL, 'u' }, { "version", no_argument, NULL, 'v' }, { "swap", no_argument, NULL, 'w' }, - { "system-idle-procs", no_argument, NULL, 'z' } + { "system-idle-procs", no_argument, NULL, 'z' }, + { NULL, 0, NULL, 0 } }; static void