Replace strncpy() with safer strlcpy() which always null-terminates.

Fixes: 7709a63bf178 ("net/softnic: add connection agent")
Cc: [email protected]

Signed-off-by: Bruce Richardson <[email protected]>
---
 drivers/net/softnic/conn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/softnic/conn.c b/drivers/net/softnic/conn.c
index 5b031358d5..d34030ce63 100644
--- a/drivers/net/softnic/conn.c
+++ b/drivers/net/softnic/conn.c
@@ -116,8 +116,8 @@ softnic_conn_init(struct softnic_conn_params *p)
        }
 
        /* Fill in */
-       strncpy(conn->welcome, p->welcome, CONN_WELCOME_LEN_MAX);
-       strncpy(conn->prompt, p->prompt, CONN_PROMPT_LEN_MAX);
+       strlcpy(conn->welcome, p->welcome, CONN_WELCOME_LEN_MAX + 1);
+       strlcpy(conn->prompt, p->prompt, CONN_PROMPT_LEN_MAX + 1);
        conn->buf_size = p->buf_size;
        conn->msg_in_len_max = p->msg_in_len_max;
        conn->msg_out_len_max = p->msg_out_len_max;
-- 
2.53.0

Reply via email to