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

Ferruh Yigit ferruh.yigit at intel.com
Wed Sep 12 15:29:13 CEST 2018


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>


More information about the dev mailing list