From 6e69fcbdfcbd1545ce2be579ef54722a550da764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tvrd=C3=ADk?= Date: Mon, 2 Nov 2015 13:40:14 +0100 Subject: [PATCH] Client: Use strncpy() instead strcpy() --- client/birdc.c | 2 +- client/client.h | 2 ++ client/commands.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/birdc.c b/client/birdc.c index ccf758be..3c6c31f1 100644 --- a/client/birdc.c +++ b/client/birdc.c @@ -78,7 +78,7 @@ static int input_complete(int arg UNUSED, int key UNUSED) { static int complete_flag; - char buf[256]; + char buf[BIRDC_INPUT_COMPLETE_BUFFER_LEN]; if (rl_last_func != input_complete) complete_flag = 0; diff --git a/client/client.h b/client/client.h index b194a772..bd1fd817 100644 --- a/client/client.h +++ b/client/client.h @@ -10,6 +10,8 @@ extern int init, busy, interactive; extern int term_lns, term_cls; +#define BIRDC_INPUT_COMPLETE_BUFFER_LEN 256 + /* birdc.c / birdcl.c */ void input_start_list(void); diff --git a/client/commands.c b/client/commands.c index 50fcba40..41baae15 100644 --- a/client/commands.c +++ b/client/commands.c @@ -195,7 +195,7 @@ cmd_find_common_match(struct cmd_node *root, char *cmd, int len, int *pcount, ch (*pcount)++; if (best < 0) { - strcpy(buf, m->token + len); + strncpy(buf, m->token + len, BIRDC_INPUT_COMPLETE_BUFFER_LEN); best = m->len - len; best_prio = m->prio; }