From patchwork Wed Aug 21 14:30:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 268819 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 74B502C00C1 for ; Thu, 22 Aug 2013 00:30:54 +1000 (EST) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=MsKIm5z7Smc91BPPR+nWrucpVzBTWuXh2sOQLtJNUFbzclaPsBTJK aUXRPnYNf0zT+8EmdjgNL91Au03szmgi+D7dthhgTBX20v5+nT+w2d2Fxam3HX/Q A0v0aC2Or2crI4sEK+o+XCW0OFM8KR6SWsKm6qqCkneKDm9iNK3kVk= 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:subject:message-id:mime-version:content-type; s= default; bh=YEK/TpdZToGdP5gPBHz5klhgpxk=; b=XFZiOeAHl41z6Zy14MNR ztkOjMqUHI/x/It6ZRktvoqcQod5XXMQ+dmxS9QtSpDchoFeSgGOIVsBGViIbONJ oWbBxsWckQN1zYo8eyJkg6rzxwb9PxxwmyqsRU3utcocG+bKCjNmSdbV+YhXxbHp mRZpJg6vuTLKH1ypMNB4Q0c= Received: (qmail 3964 invoked by alias); 21 Aug 2013 14:30:46 -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 3955 invoked by uid 89); 21 Aug 2013 14:30:46 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.2 Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 21 Aug 2013 14:30:46 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id ED4AF543241; Wed, 21 Aug 2013 16:30:40 +0200 (CEST) Date: Wed, 21 Aug 2013 16:30:40 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix buffer overflow in ipa_profile Message-ID: <20130821143034.GA24174@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Hi, as Martin noticed, there is bug in ipa_profile that first allocate order array and then introduce new local aliases before calling ipa_reverse_postorder. Fixed thus and committed as obvious. Honza Index: ChangeLog =================================================================== --- ChangeLog (revision 201891) +++ ChangeLog (working copy) @@ -1,3 +1,7 @@ +2013-08-20 Martin Liska + + * ipa.c (ipa_profile_read_summary): Fix buffer overflow. + 2013-08-20 Jan Hubicka PR bootstrap/58186 Index: ipa.c =================================================================== --- ipa.c (revision 201890) +++ ipa.c (working copy) @@ -1397,7 +1397,7 @@ ipa_profile_read_summary (void) static unsigned int ipa_profile (void) { - struct cgraph_node **order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); + struct cgraph_node **order; struct cgraph_edge *e; int order_pos; bool something_changed = false; @@ -1575,6 +1575,7 @@ ipa_profile (void) nuseless, nuseless * 100.0 / nindirect, nconverted, nconverted * 100.0 / nindirect); + order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); order_pos = ipa_reverse_postorder (order); for (i = order_pos - 1; i >= 0; i--) {