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 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/softnic/conn.c b/drivers/net/softnic/conn.c
index 5b031358d5..398f864d16 100644
--- a/drivers/net/softnic/conn.c
+++ b/drivers/net/softnic/conn.c
@@ -15,6 +15,8 @@
#include <arpa/inet.h>
#include <errno.h>
+#include <rte_string_fns.h>
+
#include "conn.h"
#define MSG_CMD_TOO_LONG "Command too long."
@@ -116,8 +118,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