mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 02:43:41 +00:00
lib: remove some strcpy, strcat
Replace with strlcpy, strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
552d6491f0
commit
9f73d2c9b6
@ -1760,10 +1760,10 @@ static int file_write_config(struct vty *vty)
|
||||
dirfd = open(".", O_DIRECTORY | O_RDONLY);
|
||||
/* if dirfd is invalid, directory sync fails, but we're still OK */
|
||||
|
||||
config_file_sav = XMALLOC(
|
||||
MTYPE_TMP, strlen(config_file) + strlen(CONF_BACKUP_EXT) + 1);
|
||||
strcpy(config_file_sav, config_file);
|
||||
strcat(config_file_sav, CONF_BACKUP_EXT);
|
||||
size_t config_file_sav_sz = strlen(config_file) + strlen(CONF_BACKUP_EXT) + 1;
|
||||
config_file_sav = XMALLOC(MTYPE_TMP, config_file_sav_sz);
|
||||
strlcpy(config_file_sav, config_file, config_file_sav_sz);
|
||||
strlcat(config_file_sav, CONF_BACKUP_EXT, config_file_sav_sz);
|
||||
|
||||
|
||||
config_file_tmp = XMALLOC(MTYPE_TMP, strlen(config_file) + 8);
|
||||
|
@ -80,8 +80,8 @@ static void opt_extend(const struct optspec *os)
|
||||
{
|
||||
const struct option *lo;
|
||||
|
||||
strcat(comb_optstr, os->optstr);
|
||||
strcat(comb_helpstr, os->helpstr);
|
||||
strlcat(comb_optstr, os->optstr, sizeof(comb_optstr));
|
||||
strlcat(comb_helpstr, os->helpstr, sizeof(comb_optstr));
|
||||
for (lo = os->longopts; lo->name; lo++)
|
||||
memcpy(comb_next_lo++, lo, sizeof(*lo));
|
||||
}
|
||||
|
@ -1365,7 +1365,7 @@ void prefix_mcast_inet4_dump(const char *onfail, struct in_addr addr,
|
||||
int save_errno = errno;
|
||||
|
||||
if (addr.s_addr == INADDR_ANY)
|
||||
strcpy(buf, "*");
|
||||
strlcpy(buf, "*", buf_size);
|
||||
else {
|
||||
if (!inet_ntop(AF_INET, &addr, buf, buf_size)) {
|
||||
if (onfail)
|
||||
|
16
lib/vty.c
16
lib/vty.c
@ -1659,7 +1659,7 @@ static struct vty *vty_create(int vty_sock, union sockunion *su)
|
||||
|
||||
/* configurable parameters not part of basic init */
|
||||
vty->v_timeout = vty_timeout_val;
|
||||
strcpy(vty->address, buf);
|
||||
strlcpy(vty->address, buf, sizeof(vty->address));
|
||||
if (no_password_check) {
|
||||
if (host.advanced)
|
||||
vty->node = ENABLE_NODE;
|
||||
@ -1795,7 +1795,7 @@ struct vty *vty_stdio(void (*atclose)(int isexit))
|
||||
*/
|
||||
vty->node = ENABLE_NODE;
|
||||
vty->v_timeout = 0;
|
||||
strcpy(vty->address, "console");
|
||||
strlcpy(vty->address, "console", sizeof(vty->address));
|
||||
|
||||
vty_stdio_resume();
|
||||
return vty;
|
||||
@ -2384,9 +2384,10 @@ static FILE *vty_use_backup_config(const char *fullpath)
|
||||
int c;
|
||||
char buffer[512];
|
||||
|
||||
fullpath_sav = malloc(strlen(fullpath) + strlen(CONF_BACKUP_EXT) + 1);
|
||||
strcpy(fullpath_sav, fullpath);
|
||||
strcat(fullpath_sav, CONF_BACKUP_EXT);
|
||||
size_t fullpath_sav_sz = strlen(fullpath) + strlen(CONF_BACKUP_EXT) + 1;
|
||||
fullpath_sav = malloc(fullpath_sav_sz);
|
||||
strlcpy(fullpath_sav, fullpath, fullpath_sav_sz);
|
||||
strlcat(fullpath_sav, CONF_BACKUP_EXT, fullpath_sav_sz);
|
||||
|
||||
sav = open(fullpath_sav, O_RDONLY);
|
||||
if (sav < 0) {
|
||||
@ -3079,8 +3080,9 @@ static void vty_save_cwd(void)
|
||||
}
|
||||
}
|
||||
|
||||
vty_cwd = XMALLOC(MTYPE_TMP, strlen(cwd) + 1);
|
||||
strcpy(vty_cwd, cwd);
|
||||
size_t vty_cwd_sz = strlen(cwd) + 1;
|
||||
vty_cwd = XMALLOC(MTYPE_TMP, vty_cwd_sz);
|
||||
strlcpy(vty_cwd, cwd, vty_cwd_sz);
|
||||
}
|
||||
|
||||
char *vty_get_cwd(void)
|
||||
|
Loading…
Reference in New Issue
Block a user