From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v2] eal: add strscpy function Date: Wed, 19 Sep 2018 11:41:32 +0200 Message-ID: <1561577.FGpAnZtoNE@xps> References: <20180911150049.14755-1-gaetan.rivet@6wind.com> <992ccee1-45c3-08d4-e743-b7490495c1e5@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, Ferruh Yigit To: Gaetan Rivet Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id DB89E255 for ; Wed, 19 Sep 2018 11:41:34 +0200 (CEST) In-Reply-To: <992ccee1-45c3-08d4-e743-b7490495c1e5@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 12/09/2018 15:29, Ferruh Yigit: > On 9/11/2018 4:00 PM, Gaetan Rivet wrote: > > The strncpy function has long been deemed unsafe for use, > > in favor of strlcpy or snprintf. > > > > While snprintf is standard and strlcpy is still largely available, > > they both have issues regarding error checking and performance. > > > > Both will force reading the source buffer past the requested size > > if the input is not a proper c-string, and will return the expected > > number of bytes copied, meaning that error checking needs to verify > > that the number of bytes copied is not superior to the destination > > size. > > > > This contributes to awkward code flow, unclear error checking and > > potential issues with malformed input. > > > > The function strscpy has been discussed for some time already and > > has been made available in the linux kernel[1]. > > > > Propose this new function as a safe alternative. > > > > [1]: http://git.kernel.org/linus/30c44659f4a3 > > > > Signed-off-by: Gaetan Rivet > > Acked-by: Juhamatti Kuusisaari > > Acked-by: Ferruh Yigit Applied, thanks