From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2018 06:30:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,364,1531810800"; d="scan'208";a="89807125" Received: from fyigit-mobl.ger.corp.intel.com (HELO [10.237.221.56]) ([10.237.221.56]) by orsmga001.jf.intel.com with ESMTP; 12 Sep 2018 06:29:14 -0700 To: Gaetan Rivet , dev@dpdk.org References: <20180911150049.14755-1-gaetan.rivet@6wind.com> From: Ferruh Yigit Openpgp: preference=signencrypt Message-ID: <992ccee1-45c3-08d4-e743-b7490495c1e5@intel.com> Date: Wed, 12 Sep 2018 14:29:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180911150049.14755-1-gaetan.rivet@6wind.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] eal: add strscpy function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Sep 2018 13:30:17 -0000 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