From patchwork Wed Aug 21 20:14:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 34236 Received: (qmail 41328 invoked by alias); 21 Aug 2019 20:14:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 41318 invoked by uid 89); 21 Aug 2019 20:14:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Aug 2019 20:14:43 +0000 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FAFF7FDF4 for ; Wed, 21 Aug 2019 20:14:42 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id h3so1744119wrw.7 for ; Wed, 21 Aug 2019 13:14:42 -0700 (PDT) Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id f6sm49647411wrh.30.2019.08.21.13.14.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Aug 2019 13:14:40 -0700 (PDT) Subject: Re: [PATCH] Fix nullptr in with_command_1 To: Tom Tromey , Bogdan Harjoc References: <87y30be94z.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Wed, 21 Aug 2019 21:14:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87y30be94z.fsf@tromey.com> On 8/2/19 7:04 PM, Tom Tromey wrote: >>>>>> "Bogdan" == Bogdan Harjoc writes: > > Bogdan> Reproduced with gdb built from git HEAD, running 'with' without > Bogdan> arguments. Patch is attached. > > This needs a ChangeLog entry. > I think a simple test case would also be good. > Ah, I could swear that I had tested this... Obviously not. I've added a test, ChangeLog entries, and merged it. Thanks for noticing/fixing this! From 26c957f12762816a90d5145c7c527ca48c890855 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 21 Aug 2019 21:11:33 +0100 Subject: [PATCH] Fix nullptr in with_command_1 Running 'with' without arguments crashes GDB. This fixes it. gdb/ChangeLog: 2019-08-21 Bogdan Harjoc * cli/cli-cmds.c (with_command_1): Error out if no arguments. gdb/testsuite/ChangeLog: 2019-08-21 Pedro Alves * gdb.base/with.exp: Test "with" with no arguments. --- gdb/ChangeLog | 4 ++++ gdb/testsuite/ChangeLog | 4 ++++ gdb/cli/cli-cmds.c | 3 +++ gdb/testsuite/gdb.base/with.exp | 2 ++ 4 files changed, 13 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 01e60fb1894..966bfb7d9fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-08-21 Bogdan Harjoc + + * cli/cli-cmds.c (with_command_1): Error out if no arguments. + 2019-08-21 Christian Biesinger * tui/tui-data.h (tui_gen_win_info): Add an =default diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 7fea9cd0712..e56cc16628d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-08-21 Pedro Alves + + * gdb.base/with.exp: Test "with" with no arguments. + 2019-08-21 Tom de Vries * gdb.base/gdb-caching-proc.exp: Sort files. diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 30e0958b60b..4fc656775c9 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -217,6 +217,9 @@ void with_command_1 (const char *set_cmd_prefix, cmd_list_element *setlist, const char *args, int from_tty) { + if (args == nullptr) + error (_("Missing arguments.")); + const char *delim = strstr (args, "--"); const char *nested_cmd = nullptr; diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index 9ea768563a3..a972296d78f 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -220,6 +220,8 @@ with_test_prefix "run control" { # Check errors. with_test_prefix "errors" { + gdb_test "with" "Missing arguments\\." + # Try both an unknown root setting and an unknown prefixed # setting. The errors come from different locations in the # sources.