{"id":807528,"url":"http://patchwork.ozlabs.org/api/patches/807528/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/59A68270.7010101@foss.arm.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<59A68270.7010101@foss.arm.com>","list_archive_url":null,"date":"2017-08-30T09:16:32","name":"[TESTSUITE] Use strncpy instead of strcpy in testsuite/gcc.dg/memcmp-1.c","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"641041d2116f32378c8975070b4c74507eb58e87","submitter":{"id":68067,"url":"http://patchwork.ozlabs.org/api/people/68067/?format=json","name":"Renlin Li","email":"renlin.li@foss.arm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/59A68270.7010101@foss.arm.com/mbox/","series":[{"id":557,"url":"http://patchwork.ozlabs.org/api/series/557/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=557","date":"2017-08-30T09:16:32","name":"[TESTSUITE] Use strncpy instead of strcpy in testsuite/gcc.dg/memcmp-1.c","version":1,"mbox":"http://patchwork.ozlabs.org/series/557/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/807528/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807528/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461139-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461139-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"G/U4MV34\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xj0Hz4zwGz9t2Q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 19:16:47 +1000 (AEST)","(qmail 83970 invoked by alias); 30 Aug 2017 09:16:39 -0000","(qmail 83942 invoked by uid 89); 30 Aug 2017 09:16:38 -0000","from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 30 Aug 2017 09:16:37 +0000","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249])\tby\n\tusa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6D83A2B;\n\tWed, 30 Aug 2017 02:16:35 -0700 (PDT)","from [10.2.207.43] (e104453-lin.cambridge.arm.com\n\t[10.2.207.43])\tby usa-sjc-imap-foss1.foss.arm.com (Postfix)\n\twith ESMTPSA id AB23B3F483; Wed, 30 Aug 2017 02:16:34 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to\n\t:from:subject:message-id:date:mime-version:content-type; q=dns;\n\ts=default; b=kJRzxSrLEIF7BpaV6db37TBd1jnMXpHJGo+8kyqVkPpPyn+elm\n\t2XmyFnG4PQPPfycvJDQiA8TqKn+ReHoFQmBxL0ozmISDq1O+6qFVnYJP8qa/kF62\n\tqM3gaGp+t09vquXgeVk+TKPHQlH4jgFpaPhYrmzLUnERta8BmVnkH34jg=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to\n\t:from:subject:message-id:date:mime-version:content-type; s=\n\tdefault; bh=zkKEcQ30gclZljuxeDt92uwIzWE=; b=G/U4MV34hLqpP8ivFTMj\n\tpzAmAz52ymWgEBiRQWdKynAL2p7FdsAxBt+mr34wZhjHZkB/P7Stnq/v60IF94dY\n\tyjITxcNFIMKQZi2/IwLykJDzPRmvQa+5x/4FBZ0J3yGCUcKj6h8rUs8LCz4XcYOR\n\tJjJ6qPEB7BRwqdvWHsRy2gs=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY,\n\tRP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*UA:38.0,\n\tH*u:38.0, renlin, visit","X-HELO":"foss.arm.com","To":"\"gcc-patches@gcc.gnu.org\" <gcc-patches@gcc.gnu.org>,\n\tacsawdey@linux.vnet.ibm.com","From":"Renlin Li <renlin.li@foss.arm.com>","Subject":"[TESTSUITE]Use strncpy instead of strcpy in\n\ttestsuite/gcc.dg/memcmp-1.c","Message-ID":"<59A68270.7010101@foss.arm.com>","Date":"Wed, 30 Aug 2017 10:16:32 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64;\n\trv:38.0) Gecko/20100101 Thunderbird/38.3.0","MIME-Version":"1.0","Content-Type":"multipart/mixed;\n\tboundary=\"------------040504000301010200060205\"","X-IsSubscribed":"yes"},"content":"Hi,\n\nIn test_driver_memcmp function, I found buf1 and buf2 is not properly\nterminated with null character.\n\nIn lib_strncmp, strcpy will be called with buf1 and buf2.\nThe normal implementation of strcpy function has a loop to copy character from source\nto destination one by one until a null character is encountered.\n\nIf the string is not properly terminated, this will cause the strcpy read/write\nmemory beyond the boundary.\n\nHere I changed the strcpy into strncpy to constraint the function to visit\nlegal memory only.\n\nTest Okay without any problem. Okay to commit?\n\nRegard,\nRenlin\n\n\ngcc/testsuite/ChangeLog:\n\n2017-08-30  Renlin Li  <renlin.li@arm.com>\n\n\t* gcc.dg/memcmp-1.c (test_strncmp): Use strncpy instead of strcpy.","diff":"diff --git a/gcc/testsuite/gcc.dg/memcmp-1.c b/gcc/testsuite/gcc.dg/memcmp-1.c\nindex 828a0ca..d258354 100644\n--- a/gcc/testsuite/gcc.dg/memcmp-1.c\n+++ b/gcc/testsuite/gcc.dg/memcmp-1.c\n@@ -110,8 +110,8 @@ static void test_strncmp_ ## SZ ## _ ## ALIGN (const char *str1, const char *str\n \t{\t\t\t\t\t\t\t\t\\\n \t  a = three+i*ALIGN+j*(4096-2*i*ALIGN);\t\t\t\t\\\n \t  b = four+i*ALIGN+j*(4096-2*i*ALIGN);\t\t\t\t\\\n-\t  strcpy(a,str1);\t\t\t\t\t\t\\\n-\t  strcpy(b,str2);\t\t\t\t\t\t\\\n+\t  strncpy(a,str1,SZ);\t\t\t\t\t\t\\\n+\t  strncpy(b,str2,SZ);\t\t\t\t\t\t\\\n \t  r = strncmp(a,b,SZ);\t\t\t\t\t\t\\\n \t  if ( r < 0 && !(expect < 0) ) abort();\t\t\t\\\n \t  if ( r > 0 && !(expect > 0) )\tabort();\t\t\t\\\n","prefixes":["TESTSUITE"]}