[dpdk-dev] [PATCH v2] eal: add strscpy function

Thomas Monjalon thomas at monjalon.net
Wed Sep 19 11:41:32 CEST 2018


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 <gaetan.rivet at 6wind.com>
> > Acked-by: Juhamatti Kuusisaari <juhamatti.kuusisaari at coriant.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit at intel.com>

Applied, thanks





More information about the dev mailing list