From owner-svn-src-all@freebsd.org Mon Apr 27 22:50:09 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8C42E2C9404; Mon, 27 Apr 2020 22:50:09 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49B0NK386Xz3L5J; Mon, 27 Apr 2020 22:50:09 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 62C011A232; Mon, 27 Apr 2020 22:50:09 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03RMo9cW038302; Mon, 27 Apr 2020 22:50:09 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03RMo8UG038299; Mon, 27 Apr 2020 22:50:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202004272250.03RMo8UG038299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 27 Apr 2020 22:50:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r360407 - in stable: 11/usr.bin/diff 11/usr.bin/diff/tests 12/usr.bin/diff 12/usr.bin/diff/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/usr.bin/diff 11/usr.bin/diff/tests 12/usr.bin/diff 12/usr.bin/diff/tests X-SVN-Commit-Revision: 360407 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 22:50:09 -0000 Author: kevans Date: Mon Apr 27 22:50:08 2020 New Revision: 360407 URL: https://svnweb.freebsd.org/changeset/base/360407 Log: MFC r357875: 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 Modified: stable/11/usr.bin/diff/diff.1 stable/11/usr.bin/diff/diff.c stable/11/usr.bin/diff/tests/diff_test.sh Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/usr.bin/diff/diff.1 stable/12/usr.bin/diff/diff.c stable/12/usr.bin/diff/tests/diff_test.sh Directory Properties: stable/12/ (props changed) Modified: stable/11/usr.bin/diff/diff.1 ============================================================================== --- stable/11/usr.bin/diff/diff.1 Mon Apr 27 22:43:24 2020 (r360406) +++ stable/11/usr.bin/diff/diff.1 Mon Apr 27 22:50:08 2020 (r360407) @@ -30,7 +30,7 @@ .\" @(#)diff.1 8.1 (Berkeley) 6/30/93 .\" $FreeBSD$ .\" -.Dd August 18, 2018 +.Dd April 27, 2020 .Dt DIFF 1 .Os .Sh NAME @@ -60,7 +60,7 @@ .Op Fl -starting-file .Op Fl -speed-large-files .Op Fl -strip-trailing-cr -.Op Fl -tabsize +.Op Fl -tabsize Ar number .Op Fl -text .Op Fl -unified .Op Fl I Ar pattern | Fl -ignore-matching-lines Ar pattern @@ -88,7 +88,7 @@ .Op Fl -speed-large-files .Op Fl -starting-file .Op Fl -strip-trailing-cr -.Op Fl -tabsize +.Op Fl -tabsize Ar number .Op Fl -text .Fl C Ar number | -context Ar number .Ar file1 file2 @@ -113,7 +113,7 @@ .Op Fl -speed-large-files .Op Fl -starting-file .Op Fl -strip-trailing-cr -.Op Fl -tabsize +.Op Fl -tabsize Ar number .Op Fl -text .Fl D Ar string | Fl -ifdef Ar string .Ar file1 file2 @@ -139,7 +139,7 @@ .Op Fl -speed-large-files .Op Fl -starting-file .Op Fl -strip-trailing-cr -.Op Fl -tabsize +.Op Fl -tabsize Ar number .Op Fl -text .Fl U Ar number | Fl -unified Ar number .Ar file1 file2 @@ -170,7 +170,7 @@ .Op Fl -show-c-function .Op Fl -speed-large-files .Op Fl -strip-trailing-cr -.Op Fl -tabsize +.Op Fl -tabsize Ar number .Op Fl -text .Op Fl -unidirectional-new-file .Op Fl -unified Modified: stable/11/usr.bin/diff/diff.c ============================================================================== --- stable/11/usr.bin/diff/diff.c Mon Apr 27 22:43:24 2020 (r360406) +++ stable/11/usr.bin/diff/diff.c Mon Apr 27 22:50:08 2020 (r360407) @@ -90,7 +90,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}, { NULL, 0, 0, '\0'} }; Modified: stable/11/usr.bin/diff/tests/diff_test.sh ============================================================================== --- stable/11/usr.bin/diff/tests/diff_test.sh Mon Apr 27 22:43:24 2020 (r360406) +++ stable/11/usr.bin/diff/tests/diff_test.sh Mon Apr 27 22:50:08 2020 (r360407) @@ -10,6 +10,7 @@ atf_test_case side_by_side atf_test_case brief_format atf_test_case b230049 atf_test_case Bflag +atf_test_case tabsize simple_body() { @@ -166,6 +167,16 @@ Bflag_body() atf_check -s exit:1 -o file:"$(atf_get_srcdir)/Bflag_F.out" diff -B E F } +tabsize_body() +{ + printf "\tA\n" > A + printf "\tB\n" > B + + atf_check -s exit:1 \ + -o inline:"1c1\n< A\n---\n> B\n" \ + diff -t --tabsize 1 A B +} + atf_init_test_cases() { atf_add_test_case simple @@ -178,4 +189,5 @@ atf_init_test_cases() atf_add_test_case brief_format atf_add_test_case b230049 atf_add_test_case Bflag + atf_add_test_case tabsize }