* [PATCH] arch: alpha: kernel: using memcpy() instead of strcpy()
@ 2013-05-29 10:51 Chen Gang
0 siblings, 0 replies; only message in thread
From: Chen Gang @ 2013-05-29 10:51 UTC (permalink / raw)
To: rth, ink, mattst88, Thomas Gleixner, Frederic Weisbecker, josh,
srivatsa.bhat
Cc: Greg KH, linux-alpha, linux-kernel@vger.kernel.org, Linux-Arch
When sending message in send_secondary_console_msg(), the length is not
include the NUL byte, and also not copy NUL to 'ipc_buffer'.
When receive message in recv_secondary_console_msg(), the 'cnt' also
excludes NUL.
So when get string from ipc_buffer, it may not be NUL terminated.
Then use memcpy() instead of strcpy(), and set last byte NUL.
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
arch/alpha/kernel/smp.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 7b60834..d3d2040 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -266,7 +266,8 @@ recv_secondary_console_msg(void)
else {
cp1 = (char *) &cpu->ipc_buffer[11];
cp2 = buf;
- strcpy(cp2, cp1);
+ memcpy(cp2, cp1, cnt);
+ cp2[cnt] = '\0';
while ((cp2 = strchr(cp2, '\r')) != 0) {
*cp2 = ' ';
--
1.7.7.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-05-29 10:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29 10:51 [PATCH] arch: alpha: kernel: using memcpy() instead of strcpy() Chen Gang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.