From patchwork Thu Sep 22 09:02:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 673233 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 3sfr9x1zL5z9sC7 for ; Thu, 22 Sep 2016 19:03:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Z8adeDI0; 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=nzGdhiTKzJh+wxks TUmcJOZQq+rG2c8sjSp3Rft/hOY3T55HRDkdx/PKGwl8Up811BVI2bxhGKwHCUtP GtpekHeR3anaTc3e+5vA1ueBC0xhx3SjvVv8vaTonuFmvdDu3CQAcRgBaoEMZkO+ OqhzcbuvMZpG0sHTcJTIE7WGJfE= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=RRUF1m6y47EXK+hvCK1J+6 3rHkg=; b=Z8adeDI0CwZHtaZf1LJ9MqSWevFcCA5XhmlE2T0lhaFtP0WKXROzQa vn7Rmv/t2ATQm7WnLOveuZKLL90R5SiUp+mPz0w0a9ggRQ9o9NMlMvptsGjVx0wp 9cPlakjmjauTAmbPFiBuGFlEBFYOtlGXPD/0klpK7QuM0KO1bWJqc= Received: (qmail 126859 invoked by alias); 22 Sep 2016 09:02:52 -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 126842 invoked by uid 89); 22 Sep 2016 09:02:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=mpfr_snprintf, mpfrval, D*Uni-Bielefeld.DE, D*DE X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Sep 2016 09:02:41 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 6A0B8623; Thu, 22 Sep 2016 11:02:38 +0200 (CEST) Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XCFcDSomAIU6; Thu, 22 Sep 2016 11:02:35 +0200 (CEST) Received: from lokon.CeBiTec.Uni-Bielefeld.DE (lokon.CeBiTec.Uni-Bielefeld.DE [129.70.161.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id A5AE1622; Thu, 22 Sep 2016 11:02:35 +0200 (CEST) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.15.2+Sun/8.15.2/Submit) id u8M92XI4007859; Thu, 22 Sep 2016 11:02:33 +0200 (MEST) From: Rainer Orth To: Martin Sebor Cc: David Malcolm , Gcc Patch List , Joseph Myers , Jeff Law , Richard Biener , Jakub Jelinek , Bernd Schmidt , Manuel =?iso-8859-15?Q?L=F3pez-Ib=E1=F1ez?= , Florian Weimer Subject: Re: [PATCH] - improve sprintf buffer overflow detection (middle-end/49905) References: <5776B33E.2080504@gmail.com> <577A8D6A.3070902@gmail.com> <578D512F.9050909@gmail.com> <9bb5ad66-4985-8c42-f800-4d84e0e18659@redhat.com> <57A3AFFF.7090109@gmail.com> <57AD30E5.3000801@gmail.com> <22a47656-c23c-4840-2e49-a59f4af513b1@redhat.com> <57B725F6.8000405@gmail.com> <110cfc6b-7856-9b51-885f-05402b14fc3e@redhat.com> <57D1B5F0.1030504@gmail.com> <57D60D03.7080601@gmail.com> <1474050251.6782.70.camel@redhat.com> Date: Thu, 22 Sep 2016 11:02:33 +0200 In-Reply-To: (Martin Sebor's message of "Tue, 20 Sep 2016 12:02:35 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Hi Martin, >> Another nit, if I may: FWIW I'm not in love with the wording of the >> messages. Sorry to bikeshed, but how about: >> warning: buffer overflow will occur when writing terminating NUL >> and: >> note: formatted output of 2 bytes into a destination of size 1 >> or somesuch. > > I won't claim the text of the messages is perfect but I did spend > a lot of time tweaking them. That's not to say they can't be > improved but changing them means quite a bit of work adjusting > the tests. At this point, I'd like to focus on getting the patch > committed. After that, if there's still time, I'm happy to take > feedback and tweak the diagnostics based on it. > > Thanks again for your help and the suggestions above! your patch broke bootstrap with MPFR 2.4.2, which is still the recommended (or perhaps minimal) version according to install.texi: /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c: In function 'int {anonymous}::format_floating_max(tree, char)': /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c:1128:27: error: 'MPFR_RNDN' was not declared in this scope mpfr_from_real (x, &rv, MPFR_RNDN); ^ /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c: In function '{anonymous}::fmtresult {anonymous}::format_floating(const {anonymous}::conversion_spec&, tree)': /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c:1328:37: error: 'MPFR_RNDN' was not declared in this scope mpfr_from_real (mpfrval, rvp, MPFR_RNDN); ^ MPFR_RNDN was only introduced in mpfr 3.0.0, and everywhere else in gcc GMP_RNDN is used instead. mpfr 3.0.0 has /* kept for compatibility with MPFR 2.4.x and before */ #define GMP_RNDN MPFR_RNDN The following patch (together with your other one to fix ILP32 targets) allows a sparc-sun-solaris2.12 bootstrap to continue. I'm going to commit it as obvious. Rainer 2016-09-22 Rainer Orth gcc: * gimple-ssa-sprintf.c (format_floating_max): Use GMP_RNDN instead of MPFR_RNDN. (format_floating): Likewise. diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -1125,7 +1127,7 @@ format_floating_max (tree type, char spe round-to-nearest mode. */ mpfr_t x; mpfr_init2 (x, rfmt->p); - mpfr_from_real (x, &rv, MPFR_RNDN); + mpfr_from_real (x, &rv, GMP_RNDN); const char fmt[] = { '%', 'R', spec, '\0' }; int n = mpfr_snprintf (NULL, 0, fmt, x); @@ -1325,7 +1327,7 @@ format_floating (const conversion_spec & round-to-nearest mode. */ mpfr_t mpfrval; mpfr_init2 (mpfrval, rfmt->p); - mpfr_from_real (mpfrval, rvp, MPFR_RNDN); + mpfr_from_real (mpfrval, rvp, GMP_RNDN); char fmtstr [40]; char *pfmt = fmtstr;