From: Chen Gang Date: Wed, 29 May 2013 10:51:28 +0000 (+0800) Subject: alpha: kernel: using memcpy() instead of strcpy() X-Git-Tag: accepted/tizen/common/20141203.182822~1800^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00ee03092a6e4b1d0ddc6b861ebb9ed8d13cc29b;p=platform%2Fkernel%2Flinux-arm64.git alpha: kernel: using memcpy() instead of strcpy() 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. Reviewed-by: Matt Turner Signed-off-by: Matt Turner Signed-off-by: Chen Gang --- diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index 53b18a6..4bc3c41 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 = ' ';