Commit 7f9b25bf authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

mount: use xsprintf() in resolve_external_mounts()

Signed-off-by: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a7e8769d
...@@ -833,7 +833,7 @@ static int resolve_external_mounts(struct mount_info *info) ...@@ -833,7 +833,7 @@ static int resolve_external_mounts(struct mount_info *info)
} }
for (m = info; m; m = m->next) { for (m = info; m; m = m->next) {
int ret, size; int ret;
char *p, *cut_root; char *p, *cut_root;
struct ext_mount *em; struct ext_mount *em;
struct mount_info *match; struct mount_info *match;
...@@ -878,19 +878,10 @@ static int resolve_external_mounts(struct mount_info *info) ...@@ -878,19 +878,10 @@ static int resolve_external_mounts(struct mount_info *info)
cut_root = cut_root_for_bind(m->root, match->root); cut_root = cut_root_for_bind(m->root, match->root);
/* +2 for the NULL byte and the extra / in the sprintf below, p = xsprintf("%s/%s", match->mountpoint + 1, cut_root);
* which we cut off in cut_root_for_bind(). */
size = strlen(match->mountpoint + 1) + strlen(cut_root) + 2;
p = xmalloc(sizeof(char) * size);
if (!p) if (!p)
return -1; return -1;
ret = snprintf(p, size, "%s/%s", match->mountpoint + 1, cut_root);
if (ret < 0 || ret >= size) {
free(p);
return -1;
}
em = xmalloc(sizeof(struct ext_mount)); em = xmalloc(sizeof(struct ext_mount));
if (!em) { if (!em) {
free(p); free(p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment