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);
{
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));
}
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)
/* 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;
*/
vty->node = ENABLE_NODE;
vty->v_timeout = 0;
- strcpy(vty->address, "console");
+ strlcpy(vty->address, "console", sizeof(vty->address));
vty_stdio_resume();
return vty;
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) {
}
}
- 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)