From cd3cefac77a5ad709ec918b09f9d7454c24ed222 Mon Sep 17 00:00:00 2001 From: Intel Date: Tue, 12 Mar 2013 12:03:00 +0100 Subject: [PATCH] cmdline: fix for long input Signed-off-by: Intel --- lib/librte_cmdline/cmdline_rdline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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]); -- 2.20.1