From patchwork Wed Oct 26 15:37:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 687133 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 3t3vKG6rQQz9sQw for ; Thu, 27 Oct 2016 02:37:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wzpF3pTi; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=mn2+9AHRu0i8tTog1YdF86+BCC5VSwUKCCXiAGg7hJDQU9blGf hGdyDne3igg0CEFVSSmBRv+JShZiBv7NtWLNFrJSDy/40r4x5p9abH8O0fXyivaV WQtpCww7x1/ixuYezxNYU/kBRpOPdYsPCCBwOg6Fp3jGK98XrLV4Fiv7E= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=rvJeJI0rBF3Dn0f2dUh4+iZzVTA=; b=wzpF3pTiW8AE7Sm53NTT LuWPxK0jkk8+iDGn/+D5pIEkTZYq6mTq0iIlqZ8pvxCUlmKt5RP6I8E/jzyg30kw xlxD9elR7DCft2N75eso+vLvKBd/TqR8u8gxXJWuUd6caN8uD/k+THRuXhM/vonW Lw1UdPtfcWDpqyeswoipp8A= Received: (qmail 32893 invoked by alias); 26 Oct 2016 15:37:14 -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 32875 invoked by uid 89); 26 Oct 2016 15:37:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 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, 26 Oct 2016 15:37:12 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B18BEC04B936 for ; Wed, 26 Oct 2016 15:37:11 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-128.phx2.redhat.com [10.3.116.128]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9QFbBoT007645 for ; Wed, 26 Oct 2016 11:37:11 -0400 To: gcc-patches@gcc.gnu.org From: Jeff Law Subject: Fix stormy16 WRT sprintf warnings Message-ID: <93c66b76-fbc7-6264-7dfb-05f4eca7ebeb@redhat.com> Date: Wed, 26 Oct 2016 09:37:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-IsSubscribed: yes [ There's at least one more port that has the exact same problem. ] stormy16's ctor/dtor output routines have this: char buf[16]; sprintf (buf, ".ctors.%.5u", /* Invert the numbering so the linker puts us in the proper order; constructors are run from right to left, and the linker sorts in increasing order. */ MAX_INIT_PRIORITY - priority); Which can overflow if depending on MAX_INIT_PRIORITY - priority. The given formatting string does _not_ limit the total number of characters printed! If that was the intent, the formatting string is wrong. Anyway, the fix is trivial, increase the buffer. Installed on the trunk. Jeff commit 41beb61397a504733a64fc6ad317d657f6b556c5 Author: law Date: Wed Oct 26 15:36:48 2016 +0000 * config/stormy16/stormy16.c (xstormy16_asm_output_destrutor): Increase buffer size. (xstormy16_asm_output_constructor): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241564 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7d869b1..d778e95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2016-10-26 Jeff Law + * config/stormy16/stormy16.c (xstormy16_asm_output_destrutor): Increase + buffer size. + (xstormy16_asm_output_constructor): Likewise. + * config/pa/pa.c (pa_asm_output_mi_thunk): Increase buffer size. diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 531a7e9..f74b4d9 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -1618,7 +1618,7 @@ static void xstormy16_asm_out_destructor (rtx symbol, int priority) { const char *section = ".dtors"; - char buf[16]; + char buf[18]; /* ??? This only works reliably with the GNU linker. */ if (priority != DEFAULT_INIT_PRIORITY) @@ -1640,7 +1640,7 @@ static void xstormy16_asm_out_constructor (rtx symbol, int priority) { const char *section = ".ctors"; - char buf[16]; + char buf[18]; /* ??? This only works reliably with the GNU linker. */ if (priority != DEFAULT_INIT_PRIORITY)