From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH v2] eal: add strscpy function Date: Wed, 12 Sep 2018 14:29:13 +0100 Message-ID: <992ccee1-45c3-08d4-e743-b7490495c1e5@intel.com> References: <20180911150049.14755-1-gaetan.rivet@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Gaetan Rivet , dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B9B614C94 for ; Wed, 12 Sep 2018 15:30:16 +0200 (CEST) In-Reply-To: <20180911150049.14755-1-gaetan.rivet@6wind.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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