if (!lxc_mkifname(template))
goto out_unlock;
- strcpy(netdev->priv.veth_attr.veth1, template);
+ (void)strlcpy(netdev->priv.veth_attr.veth1, template, IFNAMSIZ);
}
}
len = strlen(path);
p = alloca(len + 1);
- strcpy(p, path);
+ (void)strlcpy(p, path, len + 1);
+
if (!lxc_list_empty(&conf->id_map)) {
ret = chown_mapped_root(p, conf);
if (ret < 0)
struct lxc_container *lxc_container_new(const char *name, const char *configpath)
{
struct lxc_container *c;
+ size_t len;
if (!name)
return NULL;
}
remove_trailing_slashes(c->config_path);
- c->name = malloc(strlen(name)+1);
+
+ len = strlen(name);
+ c->name = malloc(len + 1);
if (!c->name) {
fprintf(stderr, "Failed to allocate memory for %s\n", name);
goto err;
}
- strcpy(c->name, name);
+ (void)strlcpy(c->name, name, len + 1);
c->numthreads = 1;
c->slock = lxc_newlock(c->config_path, name);
len = strlen(path);
copy = alloca(len + 1);
- strcpy(copy, path);
+ (void)strlcpy(copy, path, len + 1);
+
p = copy;
e = copy + len;
+
while (p < e) {
while (p < e && *p == '/')
p++;
retpath = malloc(len);
if (!retpath)
return NULL;
- strcpy(retpath, args.name);
- strcat(retpath, "/");
+ (void)strlcpy(retpath, args.name, len);
+ strncat(retpath, "/", 1);
strncat(retpath, name, name_len);
} else {
/* we're at the root of ref_tree */
if (!n->name)
return false;
- strcpy(n->name, name);
+ (void)strlcpy(n->name, name, name_len + 1);
}
if (dirname) {
- n->dirname = malloc(strlen(dirname) + 1);
+ size_t len;
+
+ len = strlen(dirname);
+ n->dirname = malloc(len + 1);
if (!n->dirname) {
free(n->name);
return false;
}
- strcpy(n->dirname, dirname);
+ (void)strlcpy(n->dirname, dirname, len + 1);
}
return true;
}