Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3637648ybg; Sun, 7 Jun 2020 06:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/cPJIWTO6DKUWc4unqkWE3udgZHGAVqIySALHY49yIH1KmrT/x8aydudUB6ij+4iiYAy/ X-Received: by 2002:aa7:c986:: with SMTP id c6mr18253692edt.335.1591535102407; Sun, 07 Jun 2020 06:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591535102; cv=none; d=google.com; s=arc-20160816; b=S/6Yy2bsWkHS2dbY4noKH3ktK+hMnWRe7NcfwLUKHAPtRIbDdV114kN4YHlm7Wd773 ITjH3SzFJK8QTU4hTwhIPJZ3R3aV9j1EzCP2KJNVZrhi/hVZWsQv8QubbgFVjYcn5ek6 9DX98U4c3BPpE+AgPKFRj5/0uyz04+FMZ1bSsbeus1Af4K9zVh6M7Eq1YLimE6wMiiPR bF9IpdbNpZCNR5MLDFOkFZzSa4/D3oGbJzrE2I5n0L+w3pDECjH+F4ycRwxlt6lBN2OD HUUA56aLSPFsU48aHh15apNn35LbEpdqrxeRSNLnHh6LSS6vTD9+++Oxcd4OX2L6OFIL 306Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=RO5RB4h7NN3mQi4Bt68TExJHFEYYdM6W1xnIG9Fg2VE=; b=Vv+C1bofpjZjIn0hPD7+97M5/WRBbZdxm7wnMeEdX8c8yV8U9HC6onHnW5Rp6+CVOJ hweIkPL7HlLoBmeQBRE7dycKij1Nwy/3IC9oKd0n/I802d/YQz1PqjjLXNVlk0cJrrI3 qqygyfMjjmJ++w21ZKWbvIcTuYSv3B37TwiiNxaBMGi9oUn6BhZcsxa2Y3ZleEXQgGno +LU3ENJgAUV51l4871uRA8B6fh1A3S3dhZ+zkzPt92DQNl3/8NBIuBIxDjJ2IQdHj9gC WhdSaZGI+Z8LsEfo7VYI+nMf0IffuaHgAgV6dLPgmebyicNXwiaMhHYFLfUmYFMBaEcq kKyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si1084049ejb.53.2020.06.07.06.04.19; Sun, 07 Jun 2020 06:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726465AbgFGNDu convert rfc822-to-8bit (ORCPT + 99 others); Sun, 7 Jun 2020 09:03:50 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:41682 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbgFGNDu (ORCPT ); Sun, 7 Jun 2020 09:03:50 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-34-niSo_StSOpacK4VCKZ_DvA-1; Sun, 07 Jun 2020 14:03:46 +0100 X-MC-Unique: niSo_StSOpacK4VCKZ_DvA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Sun, 7 Jun 2020 14:03:45 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Sun, 7 Jun 2020 14:03:45 +0100 From: David Laight To: 'Herbert Xu' , Zhangfei Gao CC: Greg Kroah-Hartman , Jonathan Cameron , wangzhou1 , "linux-kernel@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "kbuild-all@lists.01.org" Subject: RE: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy Thread-Topic: [PATCH] crypto: hisilicon - fix strncpy warning with strlcpy Thread-Index: AQHWOzNKRLAtoxLytEmaiwfeMuNV66jNIJ6A Date: Sun, 7 Jun 2020 13:03:45 +0000 Message-ID: <8c0d8f4e21794d8b80d0a3852830debb@AcuMS.aculab.com> References: <202006032110.BEbKqovX%lkp@intel.com> <1591241524-6452-1-git-send-email-zhangfei.gao@linaro.org> <20200604033918.GA2286@gondor.apana.org.au> <20200604061811.GA28759@gondor.apana.org.au> <20200604065009.GA29822@gondor.apana.org.au> <20200605121703.GA3792@gondor.apana.org.au> In-Reply-To: <20200605121703.GA3792@gondor.apana.org.au> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Herbert Xu > Sent: 05 June 2020 13:17 ... > Better yet use strscpy which will even return an error for you. It really ought to return the buffer length on truncation. Then you can loop: while(...) buf += strxxxcpy(buf, src, buf_end - buf); and only check right at the end. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)