From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48500 invoked by alias); 19 Apr 2018 14:30:55 -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 48490 invoked by uid 89); 19 Apr 2018 14:30:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=typo, ping, PING 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> <796d9b52-7270-69d4-cfc2-1ce05b6ebbf1@linux.vnet.ibm.com> <980fefe5-31ac-e5be-afb5-102b873dc567@linux.vnet.ibm.com> From: Stefan Liebler Date: Thu, 19 Apr 2018 14:30: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: <980fefe5-31ac-e5be-afb5-102b873dc567@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18041914-0020-0000-0000-00000413BB48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041914-0021-0000-0000-000042A8083B Message-Id: <06aaed94-4461-98a1-2ec2-e8cdf5355e65@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-19_05:,, 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-1804190128 X-SW-Source: 2018-04/txt/msg00397.txt.bz2 On 04/12/2018 05:31 PM, Stefan Liebler wrote: > On 04/05/2018 06:14 PM, Andreas Schwab wrote: >> On Apr 05 2018, Stefan Liebler wrote: >> >>> Why do we need the strncpy at all? >>> if (len == 0 && ...) >> >> That's obviously a typo. >> >> Andreas. >> > Yes. You are right. Please have a look at the applied patch. > If the zero-termination is needed, numstr is copied to the buffer with > strncpy and the zero-termination is applied. > If numstr is either 0 bytes long or the length of the numstr string is > 0, then _nss_nisplus_parse_pwent returns with 0. > > > This solves the mentioned warning with if build with gcc-head and > --enable-obsolete-nsl. > But I can not test it as I don't have a nisplus setup. > > Bye. > Stefan PING