From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 3F45A3858D29 for ; Mon, 22 Mar 2021 05:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3F45A3858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3CCCCAD74; Mon, 22 Mar 2021 05:43:26 +0000 (UTC) Date: Mon, 22 Mar 2021 06:43:24 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [PATCH] Don't allow implicit file argument in combination with -o Message-ID: <20210322054323.GA2676@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2021 05:43:32 -0000 Hi, Consider this dwz usage: ... $ gcc ~/hello.c -g $ dwz -o b.out $ ... According to the advertised usage: ... $ dwz -? Usage: dwz [common options] [-h] [-m COMMONFILE] [-M NAME | -r] [FILES] dwz [common options] -o OUTFILE FILE dwz [ -v | -? ] ... the FILE argument is required when using -o OUTFILE. Fix this by erroring out instead: ... $ dwz -o b.out dwz: Cannot use implicit file in combination with -o option ... [ Alternatively, we could update the advertised usage. ] Any comments? Thanks, - Tom Don't allow implicit file argument in combination with -o 2021-03-22 Tom de Vries PR dwz/27595 * dwz.c (main): Don't allow implicit file argument in combination with -o. * testsuite/dwz.tests/pr27595.sh: New test. --- dwz.c | 3 +++ testsuite/dwz.tests/pr27595.sh | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/dwz.c b/dwz.c index a7aa23b..fe191ba 100644 --- a/dwz.c +++ b/dwz.c @@ -16428,6 +16428,9 @@ main (int argc, char *argv[]) { const char *file = nr_files == 0 ? "a.out" : files[0]; + if (nr_files == 0 && outfile != NULL) + error (1, 0, "Cannot use implicit file in combination with -o option"); + if (multifile != NULL) { error (0, 0, "Too few files for multifile optimization"); diff --git a/testsuite/dwz.tests/pr27595.sh b/testsuite/dwz.tests/pr27595.sh new file mode 100644 index 0000000..bd459be --- /dev/null +++ b/testsuite/dwz.tests/pr27595.sh @@ -0,0 +1,11 @@ +cp $execs/hello a.out + +if dwz -o b.out 2> dwz.err; status=$?; then + true +fi + +[ $status -eq 1 ] + +grep -q "Cannot use implicit file in combination with -o option" dwz.err + +rm -f a.out dwz.err