From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27743 invoked by alias); 30 Aug 2018 22:31:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27523 invoked by uid 89); 30 Aug 2018 22:30:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=by, sk:get_ran, non-string, H*f:sk:a0d277c 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; Thu, 30 Aug 2018 22:30:52 +0000 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D1835F757; Thu, 30 Aug 2018 22:30:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-11.rdu2.redhat.com [10.10.112.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id D42212010CAB; Thu, 30 Aug 2018 22:30:35 +0000 (UTC) Subject: Re: [PATCH 3/6] detect unterminated const arrays in strcpy calls (PR 86552) To: Martin Sebor , Gcc Patch List References: From: Jeff Law Openpgp: preference=signencrypt Message-ID: Date: Thu, 30 Aug 2018 22:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg02003.txt.bz2 On 08/13/2018 03:27 PM, Martin Sebor wrote: > The attached changes implement the detection of past-the-end reads > by strcpy due to unterminated arguments. > > gcc-86552-3.diff > > > PR tree-optimization/86552 - missing warning for reading past the end of non-string arrays > > gcc/ChangeLog: > > * builtins.c (unterminated_array): New. > (expand_builtin_strcpy): Adjust. > (expand_builtin_strcpy_args): Detect unterminated arrays. > * gimple-fold.c (get_maxval_strlen): Add argument. Detect > unterminated arrays. > * gimple-fold.h (get_maxval_strlen): Add argument. > (gimple_fold_builtin_strcpy): Detec unterminated arrays. > > gcc/testsuite/ChangeLog: > > * gcc.dg/warn-strcpy-no-nul.c: New test. >From a review standpoint this is essentially in the same state as patch #2. It depends on bits that haven't been installed (yet) and needs trivial API updates. There's one test that is an XPASS which is clearly a derived from the same test that is an XPASS in patch #2. While reviewing I noticed that get_maxval_strlen didn't have a function comment. So I added one. get_maxval_strlen will likely need further refinement of its comment or code once get_range_strlen gets revamped. As with patch #2 in this series, I'll own posting the final patch and committing the bits. jeff