From patchwork Wed May 13 08:51:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 471757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E55F014078C for ; Wed, 13 May 2015 18:51:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TV5T7ZGM; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=wuGu9lObAmg8hDQh0vdjTXagke22Q4vArhhkI0sAfuxBhp k3c9B8r/wmDjMFmKYEZXVJ5PGWLJirfqNlEcSRlrgJY+4DK59Z1ySVczcokG6DUg iouQB+vOz/DYkiD08pOkd7+dCQ348Bkmvdb/oeEB7OqZM0qhS64krflYxLRX8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=tGBYtHVCsuosZc3uYjLFQnfRaLo=; b=TV5T7ZGMjk/1VHUWb1tp f6H4tcH6aVezWPbPiYTptAFLDb/N94/yqhFIxqraC1htxB80bulS0AKBiuhnW+Hg VWphO//HPZstWw0jO8Rt1JUxAFpMQ76NPqof5A2PZ1/nmkABaA+FveNT4yGsN/m2 Np4bqvsRZWW5aXfg1UKxNxM= Received: (qmail 117472 invoked by alias); 13 May 2015 08:51:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 117405 invoked by uid 89); 13 May 2015 08:51:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 13 May 2015 08:51:15 +0000 Received: by qkgy4 with SMTP id y4so23552289qkg.2 for ; Wed, 13 May 2015 01:51:13 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.229.84.70 with SMTP id i6mr26204645qcl.20.1431507073085; Wed, 13 May 2015 01:51:13 -0700 (PDT) Received: by 10.229.215.4 with HTTP; Wed, 13 May 2015 01:51:12 -0700 (PDT) Date: Wed, 13 May 2015 10:51:12 +0200 Message-ID: Subject: [PATCH 2/7] [D] libiberty: Fail if reached end of symbol string From: Iain Buclaw To: gcc-patches , Ian Lance Taylor X-IsSubscribed: yes If a symbol that has so far been valid abruptly ends then we will want to fail the process rather than silently succeed. --- libiberty/ChangeLog 2015-05-13 Iain Buclaw * d-demangle.c (dlang_call_convention): Return NULL if have reached the end of the symbol, but expected more. (dlang_attributes): Likewise. (dlang_function_type): Likewise. (dlang_type): Likewise. (dlang_identifier): Likewise. (dlang_value): Likewise. From e9806a182f8296d92a99d842edab6a4c29124eb1 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Wed, 13 May 2015 08:50:55 +0200 Subject: [PATCH 2/7] D demangle: Fail early on bad symbols --- libiberty/d-demangle.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index fa01767..91c6d55 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -185,7 +185,7 @@ static const char * dlang_call_convention (string *decl, const char *mangled) { if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; switch (*mangled) { @@ -221,7 +221,7 @@ static const char * dlang_attributes (string *decl, const char *mangled) { if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; while (*mangled == 'N') { @@ -280,7 +280,7 @@ dlang_function_type (string *decl, const char *mangled) size_t szattr, szargs, sztype; if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; /* The order of the mangled string is: CallConvention FuncAttrs Arguments ArgClose Type @@ -380,7 +380,7 @@ static const char * dlang_type (string *decl, const char *mangled) { if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; switch (*mangled) { @@ -600,7 +600,7 @@ static const char * dlang_identifier (string *decl, const char *mangled) { if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; if (ISDIGIT (*mangled)) { @@ -1061,7 +1061,7 @@ static const char * dlang_value (string *decl, const char *mangled, const char *name, char type) { if (mangled == NULL || *mangled == '\0') - return mangled; + return NULL; switch (*mangled) { -- 2.1.0