From patchwork Tue Jul 26 15:42:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Vogt X-Patchwork-Id: 652811 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 3rzMp10hhRz9srX for ; Wed, 27 Jul 2016 01:42:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PH1DKnQT; 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:date :from:to:cc:subject:reply-to:mime-version:content-type :message-id; q=dns; s=default; b=wpG6YHES9A1ryOEjVy+ELlU2sKmonhY /M9U43R92l3HR8JDaFg6NIFQ/ikvFDI4PBXf7/WTU26mZZSUmrhKG2Q51HIHJBKK ru8e4u/P7UPvCd3vU/kPiwlbXA5a39CFiqFYqYHQI7E85eB/Ypla7fW6z+juFpy6 X3SWrKf+odUo= 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:date :from:to:cc:subject:reply-to:mime-version:content-type :message-id; s=default; bh=jLlTirmP07nAgBIwApS+BJqx5Y8=; b=PH1DK nQT/p6Y9ewAdeMt35rL+8dBlKvLQ9vztyvr+BMy895QFXpkr3bEVLMEfAjuT9af7 xut6VFvIyT0Fs0qoYSiQYoMerJy1Ja1VZrH0EEZ3iPkP7nbONs36UfdoCoQLu8Sq H1XAiccELl/GV3pr6FeuH6GyxEd0n3l3/RkTUA= Received: (qmail 89748 invoked by alias); 26 Jul 2016 15:42:37 -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 89723 invoked by uid 89); 26 Jul 2016 15:42:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=H*m:linux, Hx-languages-length:1356, UD:ar X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 26 Jul 2016 15:42:26 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6QFZ3pm059653 for ; Tue, 26 Jul 2016 11:42:23 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 24dsrp5b4c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 26 Jul 2016 11:42:22 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Jul 2016 16:42:20 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 26 Jul 2016 16:42:18 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: vogt@linux.vnet.ibm.com X-IBM-RcptTo: fortran@gcc.gnu.org;gcc-patches@gcc.gnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id DA0432190023; Tue, 26 Jul 2016 16:41:44 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6QFgHtG9372000; Tue, 26 Jul 2016 15:42:18 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6QFgHq8032000; Tue, 26 Jul 2016 09:42:17 -0600 Received: from oc5510024614.ibm.com (sig-9-145-21-190.uk.ibm.com [9.145.21.190]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u6QFgHTi031990; Tue, 26 Jul 2016 09:42:17 -0600 Received: by oc5510024614.ibm.com (Postfix, from userid 500) id AFA6917DC9; Tue, 26 Jul 2016 17:42:14 +0200 (CEST) Date: Tue, 26 Jul 2016 16:42:13 +0100 From: Dominik Vogt To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Cc: Andreas Krebbel Subject: [PATCH] gfortran: Fix allocation of diagnostig string (was too small). Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: vogt@linux.vnet.ibm.com, gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org, Andreas Krebbel MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072615-0008-0000-0000-000002A5DC19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072615-0009-0000-0000-0000193BBCF8 Message-Id: <20160726154213.GA5371@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-26_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607260169 The attached patch fixes an out of bound write to memory allocated with alloca() on the stack. This rarely ever happened because on one hand -fbounds-check needs to be enabled, and on the other hand alloca() used to allocate a few bytes extra most of the time so most of the time the excess write did no harm. Ciao Dominik ^_^ ^_^ diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index e95c8dd..7572755 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3332,7 +3332,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_expr *expr, if (ref->type == REF_ARRAY && &ref->u.ar == ar) break; if (ref->type == REF_COMPONENT) - len += 1 + strlen (ref->u.c.component->name); + len += 2 + strlen (ref->u.c.component->name); } var_name = XALLOCAVEC (char, len);