From: Intel Date: Tue, 12 Mar 2013 11:03:00 +0000 (+0100) Subject: cmdline: fix for long input X-Git-Tag: spdx-start~11296 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cd3cefac77a5ad709ec918b09f9d7454c24ed222;p=dpdk.git cmdline: fix for long input Signed-off-by: Intel --- diff --git a/lib/librte_cmdline/cmdline_rdline.c b/lib/librte_cmdline/cmdline_rdline.c index 0f99e618a4..1d0e51b20e 100644 --- a/lib/librte_cmdline/cmdline_rdline.c +++ b/lib/librte_cmdline/cmdline_rdline.c @@ -118,9 +118,10 @@ rdline_newline(struct rdline *rdl, const char *prompt) cirbuf_init(&rdl->left, rdl->left_buf, 0, RDLINE_BUF_SIZE); cirbuf_init(&rdl->right, rdl->right_buf, 0, RDLINE_BUF_SIZE); + rdl->prompt_size = strnlen(prompt, RDLINE_PROMPT_SIZE-1); if (prompt != rdl->prompt) - memcpy(rdl->prompt, prompt, sizeof(rdl->prompt)-1); - rdl->prompt_size = strnlen(prompt, RDLINE_PROMPT_SIZE); + memcpy(rdl->prompt, prompt, rdl->prompt_size); + rdl->prompt[RDLINE_PROMPT_SIZE-1] = '\0'; for (i=0 ; iprompt_size ; i++) rdl->write_char(rdl, rdl->prompt[i]);