bsps/shared/ofw: Use strlcpy instead of strncpy

Changed rtems_ofw_get_prop to use strlcpy instead of strncpy
to ensure the buffer is null terminated incase of overflow.
This commit is contained in:
G S Niteesh Babu
2021-02-08 21:08:36 +01:00
committed by Christian Mauderer
parent c4985b7718
commit 066687c43a
+9 -1
View File
@@ -198,7 +198,15 @@ ssize_t rtems_ofw_get_prop(
if (prop == NULL && strcmp(propname, "name") == 0) {
prop = fdt_get_name(fdtp, offset, &len);
strncpy(buf, prop, bufsize);
/* Node name's are 1-31 chars in length consisting of only
* ascii chars and are null terminated */
strlcpy(buf, prop, bufsize);
/* Return the length of the name including the null byte
* rather than the amount copied.
* This is the behaviour in libBSD ofw_fdt_getprop
*/
return len + 1;
}