mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-06 05:17:59 +00:00
Replace a few more str(n)dupa by str(n)dup + free
strdup and strndup still don't exist on bionic, so we need to do the alloc() call ourselves or free the memory by hand. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
1d374b9725
commit
d74325c436
@ -1602,7 +1602,8 @@ static int overlayfs_mount(struct bdev *bdev)
|
||||
|
||||
// separately mount it first
|
||||
// mount -t overlayfs -oupperdir=${upper},lowerdir=${lower} lower dest
|
||||
dup = strdupa(bdev->src);
|
||||
dup = alloca(strlen(bdev->src)+1);
|
||||
strcpy(dup, bdev->src);
|
||||
if (!(lower = index(dup, ':')))
|
||||
return -22;
|
||||
if (!(upper = index(++lower, ':')))
|
||||
@ -1770,7 +1771,8 @@ static int overlayfs_create(struct bdev *bdev, const char *dest, const char *n,
|
||||
return -1;
|
||||
}
|
||||
|
||||
delta = strdupa(dest);
|
||||
delta = alloca(strlen(dest)+1);
|
||||
strcpy(delta, dest);
|
||||
strcpy(delta+len-6, "delta0");
|
||||
|
||||
if (mkdir_p(delta, 0755) < 0) {
|
||||
|
@ -184,13 +184,15 @@ extern int mkdir_p(const char *dir, mode_t mode)
|
||||
do {
|
||||
dir = tmp + strspn(tmp, "/");
|
||||
tmp = dir + strcspn(dir, "/");
|
||||
makeme = strndupa(orig, dir - orig);
|
||||
makeme = strndup(orig, dir - orig);
|
||||
if (*makeme) {
|
||||
if (mkdir(makeme, mode) && errno != EEXIST) {
|
||||
SYSERROR("failed to create directory '%s'\n", makeme);
|
||||
free(makeme);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
free(makeme);
|
||||
} while(tmp != dir);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user