From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63644 invoked by alias); 5 Apr 2018 15:57:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 63635 invoked by uid 89); 5 Apr 2018 15:57:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,URIBL_RED autolearn=no version=3.3.2 spammy=nis X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH] Replace strncpy with memccpy to fix -Wstringop-truncation. To: libc-alpha@sourceware.org References: <20180323010729.41457-1-raj.khem@gmail.com> From: Stefan Liebler Date: Thu, 05 Apr 2018 15:57:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18040515-0020-0000-0000-0000040E7EB5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040515-0021-0000-0000-000042A29421 Message-Id: <796d9b52-7270-69d4-cfc2-1ce05b6ebbf1@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-05_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804050166 X-SW-Source: 2018-04/txt/msg00144.txt.bz2 On 03/23/2018 02:29 AM, Khem Raj wrote: > Hi Joseph > > On Thu, Mar 22, 2018 at 6:17 PM, Joseph Myers wrote: >> On Thu, 22 Mar 2018, Khem Raj wrote: >> >>> * nis/nss_nisplus/nisplus-parser.c: Replace strncpy with memcpy to >>> avoid -Wstringop-truncation. >> >> Could you give more details of (a) in what circumstances (architecture, >> compiler, etc.) you get this warning and (b) why the truncation is >> correct? >> >> Whatever build failure you got hasn't shown up with build-many-glibcs.py. >> Maybe that should include a configuration with --enable-obsolete-rpc >> --enable-obsolete-nsl to make sure that it tests building those bits of >> code that are disabled by default? >> > > This is seen with gcc/trunk when cross compiling for armv7ve target > and yes --enable-obsolete-rpc is used to configure, I am using > OpenEmbedded build system. > > nss_nisplus/nisplus-parser.c:90:7: error: 'strncpy' destination > unchanged after copying no bytes [-Werror=stringop-truncation] > strncpy (first_unused, numstr, len); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > nss_nisplus/nisplus-parser.c:106:7: error: 'strncpy' destination > unchanged after copying no bytes [-Werror=stringop-truncation] > strncpy (first_unused, numstr, len); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Hi, I also see those warnings on s390x if build with gcc-head (from today) and if glibc is configured with --enable-obsolete-nsl. Why do we need the strncpy at all? if (len == 0 && ...) { ... strncpy (first_unused, numstr, len); first_unused[len] = '\0'; ... } Bye. Stefan