From patchwork Mon Oct 24 21:51:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 16774 Received: (qmail 94035 invoked by alias); 24 Oct 2016 21:52:17 -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 94000 invoked by uid 89); 24 Oct 2016 21:52:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Oct 2016 21:52:06 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1bynA4-00050J-Ji from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Mon, 24 Oct 2016 14:52:04 -0700 Received: from Opsys.world.mentorg.com (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Mon, 24 Oct 2016 14:52:03 -0700 From: Luis Machado To: Subject: [PATCH] Fix obvious gotcha in string comparison Date: Mon, 24 Oct 2016 16:51:59 -0500 Message-ID: <1477345919-32239-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch fixes a gotcha when comparing exception's messages in exception_print_same. It should've used the statically-allocated string versions msg1 and msg2 instead. As is, it could lead to crashes. gdb/ChangeLog: 2016-10-24 Luis Machado * exec.c (exception_print_same): Fix string comparison to use statically-allocated ones. --- gdb/ChangeLog | 5 +++++ gdb/exec.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index be72369..388cc1f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-10-24 Luis Machado + + * exec.c (exception_print_same): Fix string comparison to use + statically-allocated ones. + 2016-10-21 Tom Tromey * dwarf2expr.h (class dwarf_expr_context) diff --git a/gdb/exec.c b/gdb/exec.c index d858e99..67ecc63 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -152,7 +152,7 @@ exception_print_same (struct gdb_exception e1, struct gdb_exception e2) return (e1.reason == e2.reason && e1.error == e2.error - && strcmp (e1.message, e2.message) == 0); + && strcmp (msg1, msg2) == 0); } /* See gdbcore.h. */