[Skiboot] [PATCH v4 8/8] slw: use strncpy instead of strcpy

Shreyas B. Prabhu shreyas at linux.vnet.ibm.com
Thu Jun 16 23:56:20 AEST 2016


Use strncpy instead of strcpy while appending to name_buf.

Suggested-by: Michael Neuling <mikey at neuling.org>
Signed-off-by: Shreyas B. Prabhu <shreyas at linux.vnet.ibm.com>
---
 hw/slw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/slw.c b/hw/slw.c
index 748e319a58b4..f174ae4f3462 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -35,6 +35,7 @@
 #include <sbe_xip_image.h>
 
 #define MAX_RESET_PATCH_SIZE	64
+
 static uint32_t slw_saved_reset[MAX_RESET_PATCH_SIZE];
 
 static bool slw_current_le = false;
@@ -689,7 +690,7 @@ void add_cpu_idle_state_properties(void)
 		 * If a state is supported add each of its property
 		 * to its corresponding property buffer.
 		 */
-		strcpy(name_buf, states[i].name);
+		strncpy(name_buf, states[i].name, MAX_NAME_LEN);
 		name_buf = name_buf + strlen(states[i].name) + 1;
 
 		*latency_ns_buf = cpu_to_fdt32(states[i].latency_ns);
-- 
1.9.3



More information about the Skiboot mailing list