From patchwork Wed Jan 8 18:47:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1219858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516941-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DAdQZWse"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="S+H1+ovU"; dkim-atps=neutral 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 47tJCr1WbCz9sPK for ; Thu, 9 Jan 2020 05:48:08 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=BmChJ WVhZr3JV/BzI3/mbFvttFQk9c1WkpU0lG3Al9hHxtPLZiOEzScCBcuIR4JgVhd5R j7nDi1cQ98bkWpViSZNt0HVUuA9M+YTGHNcRcvAyKGwx53E2CO/5d4s0v/HTmIY6 h51Xf5qJay6JEqvvyN0DYL7b88T+aaGol85wyM= 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 :message-id:subject:from:reply-to:to:cc:date:in-reply-to :references:mime-version:content-type; s=default; bh=Sdce1fZ6lbA Ab+cLtjfaoFzB63o=; b=DAdQZWseNwVpLh3Qckok/TfJS8KjY02k1bamPU7p3oN 7YYPsEwD3D8DNH4ukwrx942rL6XVc4uoov9ZROkugbnfq7Nu4kFPf6Hr82xK6/IH dZ3kF4gSIdzds9QBgbgWqxtIuV/coKL7de4hpG3FtEIk1z+ysJmE2DxBsVi/T4so = Received: (qmail 82986 invoked by alias); 8 Jan 2020 18:48:01 -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 82968 invoked by uid 89); 8 Jan 2020 18:48:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Jan 2020 18:47:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578509277; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=/FHvy/+GRQ/0Ld3CE6iU3KSlTTYvigxP4E/kkuuA04M=; b=S+H1+ovU4NGshzZofypuQzNGwL2TsCVKQMxUs+7Uoz5Jn26tq/ieF6u5sX5XrowAzj+CaC 2uNJe5GOjU3PQ/frB69Hhl1Jb9ThkAnGLwdHyuwPyzHQhOPnDXCB9Ij0PB7UpPayknxrQs lxbIhgcHLlDIYFuzhGwIKUmcrY1H3Zw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-95-qtq5qY2YNaOxjfDbMM1gMw-1; Wed, 08 Jan 2020 13:47:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0E9D10054E3; Wed, 8 Jan 2020 18:47:52 +0000 (UTC) Received: from ovpn-112-38.phx2.redhat.com (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A96C272C4; Wed, 8 Jan 2020 18:47:51 +0000 (UTC) Message-ID: <57341c74051a1273aa54e5401277cb52b9410826.camel@redhat.com> Subject: [committed] Make Wstringop-overflow-27 testnames unique [was Re: [PING 3][PATCH] track dynamic allocation in strlen (PR 91582)] From: Jeff Law Reply-To: law@redhat.com To: Andreas Schwab , Martin Sebor Cc: gcc-patches Date: Wed, 08 Jan 2020 11:47:51 -0700 In-Reply-To: References: <081f0235-96b3-988b-5605-ed5a0805b3c7@gmail.com> <5cf529c3-f69a-46c8-93fc-cce673e02b5c@gmail.com> <4e6a8395-0bc7-8820-7222-99a3bf3d2f3a@gmail.com> User-Agent: Evolution 3.34.2 (3.34.2-1.fc31) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes On Wed, 2020-01-08 at 12:52 +0100, Andreas Schwab wrote: > On Dez 06 2019, Martin Sebor wrote: > > > diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c > > new file mode 100644 > > index 00000000000..249ce2b6ad5 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c > > +void test_strcpy_warn (const char *s) > > +{ > > + { > > + const char a[] = "123"; > > + /* Verify that using signed int for the strlen result works (i.e., > > + that the conversion from signed int to size_t doesn't prevent > > + the detection. */ > > + int n = strlen (a); > > + char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note" { xfail *-*-* } } > > + // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note" { target *-*-* } .-1 } > > Please make the test name unique. > > > + strcpy (t, a); // { dg-warning "writing 4 bytes into a region of size (between 0 and )?3 " } > > + > > + sink (t); > > + } > > + > > + { > > + const char a[] = "1234"; > > + size_t n = strlen (a); > > + char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note" { xfail *-*-* } } > > + // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note" { target *-*-* } .-1 } > > Likewise. Fixed via the attached patch which I've committed to the trunk. jeff commit 48e76be17adbf93fe264fc118adbcf2ae6a14806 Author: law Date: Wed Jan 8 18:46:33 2020 +0000 * gcc.dg/Wstringop-overflow-27.c: Make testnames unique. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@280016 138bc75d-0d04-0410-961f-82ee72b054a4 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 537091ffec6..622589e3db6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-01-08 Jeff Law + + * gcc.dg/Wstringop-overflow-27.c: Make testnames unique. + 2020-01-08 Joel Brobecker Olivier Hainque diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c index 249ce2b6ad5..8e2cfe30725 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-27.c @@ -260,8 +260,8 @@ void test_strcpy_warn (const char *s) that the conversion from signed int to size_t doesn't prevent the detection. */ int n = strlen (a); - char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note" { xfail *-*-* } } - // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note" { target *-*-* } .-1 } + char *t = (char*)calloc (n, 1); // { dg-message "at offset 0 to an object with size 3 allocated by 'calloc' here" "calloc note 1" { xfail *-*-* } } + // { dg-message "at offset 0 to an object with size at most 3 allocated by 'calloc' here" "calloc note 2" { target *-*-* } .-1 } strcpy (t, a); // { dg-warning "writing 4 bytes into a region of size (between 0 and )?3 " } sink (t); @@ -270,8 +270,8 @@ void test_strcpy_warn (const char *s) { const char a[] = "1234"; size_t n = strlen (a); - char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note" { xfail *-*-* } } - // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note" { target *-*-* } .-1 } + char *t = (char*)malloc (n); // { dg-message "at offset 0 to an object with size 4 allocated by 'malloc' here" "malloc note 1" { xfail *-*-* } } + // { dg-message "at offset 0 to an object with size at most 4 allocated by 'malloc' here" "malloc note 2" { target *-*-* } .-1 } strcpy (t, a); // { dg-warning "writing 5 bytes into a region of size (between 0 and )?4 " } sink (t); }