aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Grohmann <davide.grohmann@arm.com>2022-05-17 16:11:14 +0200
committerDavide Grohmann <davide.grohmann@arm.com>2022-05-18 12:10:07 +0200
commit6ab0b6ba4dec4b0faadf310891b15de382db396f (patch)
treee31c745bfbc4150be0b7ccc58a69ab1562e80aad
parent8b1fe55bf4788ac85a0d8f9059ca0305904ddc5d (diff)
downloadethos-u-linux-driver-stack-6ab0b6ba4dec4b0faadf310891b15de382db396f.tar.gz
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
-rw-r--r--kernel/ethosu_network_info.c6
1 files changed, 5 insertions, 1 deletions
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++)