From 6ab0b6ba4dec4b0faadf310891b15de382db396f Mon Sep 17 00:00:00 2001 From: Davide Grohmann Date: Tue, 17 May 2022 16:11:14 +0200 Subject: Replace usage of forbidden strncpy with strscpy strscpy copies max destination size -1 chars and ensures NULL termination. It also return an error if the destination buffer is too small. Change-Id: I88e9e5020b2b26ca50c12ae845dad070855a8bde --- kernel/ethosu_network_info.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/ethosu_network_info.c b/kernel/ethosu_network_info.c index c2b6caa..ebb059c 100644 --- a/kernel/ethosu_network_info.c +++ b/kernel/ethosu_network_info.c @@ -192,7 +192,11 @@ void ethosu_network_info_rsp(struct ethosu_device *edev, goto signal_complete; } - strncpy(info->uapi->desc, rsp->desc, sizeof(info->uapi->desc)); + ret = strscpy(info->uapi->desc, rsp->desc, sizeof(info->uapi->desc)); + if (ret < 0) { + info->errno = ret; + goto signal_complete; + } info->uapi->ifm_count = rsp->ifm_count; for (i = 0; i < rsp->ifm_count; i++) -- cgit v1.2.1