Commit 00ee0309 authored by Chen Gang's avatar Chen Gang Committed by Matt Turner

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: default avatarMatt Turner <mattst88@gmail.com>
Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
parent 29b7a47a
......@@ -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 = ' ';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment