From 43fbd654516eb5ddfa2994d92b7dfd373192796e Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 13 Feb 2020 20:23:55 +0000 Subject: diff: fix segfault with --tabsize and no/malformed argument --tabsize was previously listed as optional_argument, but didn't account for the optionality of it in the argument handling. This is irrelevant -- the manpage doesn't indicate that the argument is optional, and indeed there's no clear interpretation of omitting the argument because there's no other side effect of --tabsize. The "malformed" argument part of the header on this message is simply referring to usage like this: % diff --tabsize 4 A B With an optional_argument, the argument must be attached to the parameter directly (e.g. --tabsize=4), so the argument is effectively NULL with the above invocation as if no argument had been passed. PR: 243974 Submitted by: fehmi noyan isi (diff.c portion) MFC after: 3 days --- usr.bin/diff/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.bin/diff/diff.c') diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index e2e65e520cb5..a4e86b7855a8 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -93,7 +93,7 @@ static struct option longopts[] = { { "no-ignore-file-name-case", no_argument, NULL, OPT_NO_IGN_FN_CASE }, { "normal", no_argument, NULL, OPT_NORMAL }, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, - { "tabsize", optional_argument, NULL, OPT_TSIZE }, + { "tabsize", required_argument, NULL, OPT_TSIZE }, { "changed-group-format", required_argument, NULL, OPT_CHANGED_GROUP_FORMAT}, { "suppress-common-lines", no_argument, NULL, OPT_SUPPRESS_COMMON }, { NULL, 0, 0, '\0'} -- cgit v1.2.3