Thread (3 messages) read the whole thread 3 messages, 2 authors, 2013-01-30

[PATCH] ARM:mach-msm: seting tail NUL after strncpy

From: bjorn@mork.no (Bjørn Mork)
Date: 2013-01-30 09:20:31
Also in: linux-arm-msm

Possibly related (same subject, not in this thread)

Chen Gang [off-list ref] writes:
quoted hunk
  temp need NUL terminated, or next ptr may cause issue.

Signed-off-by: Chen Gang <redacted>
---
 arch/arm/mach-msm/clock-debug.c |    2 ++
 1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-msm/clock-debug.c
b/arch/arm/mach-msm/clock-debug.c
index 4886404..bdca900 100644
--- a/arch/arm/mach-msm/clock-debug.c
+++ b/arch/arm/mach-msm/clock-debug.c
@@ -105,6 +105,8 @@ int __init clock_debug_add(struct clk *clock)
 		return -ENOMEM;

 	strncpy(temp, clock->dbg_name, ARRAY_SIZE(temp)-1);
+	temp[ARRAY_SIZE(temp)-1] = '\0';
+
 	for (ptr = temp; *ptr; ptr++)
 		*ptr = tolower(*ptr);
Maybe use strlcpy() instead?


Bj?rn
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help