mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-23 02:34:01 +08:00
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:
committed by
Christian Mauderer
parent
c4985b7718
commit
066687c43a
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user