From: Andrei Tatar Date: Tue, 29 Apr 2025 13:54:03 +0000 (+0200) Subject: lib/vfscore: Fix write const path in automount X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=faaecca04a509dfc6bd0a0c3f7866f7f0162f1a8;p=unikraft%2Funikraft.git lib/vfscore: Fix write const path in automount Previously vfscore_mount_volume would pass a const path to vfscore_ukopt_mkmp, which expects a mutable path, and indeed does modify it in-place during execution. This is wrong and rightfully triggers a compiler warning. This change fixes this by having mkmp allocate a temporary writable path. Checkpatch-Ignore: STRCPY Signed-off-by: Andrei Tatar Reviewed-by: Michalis Pappas Approved-by: Michalis Pappas GitHub-Closes: #1636 --- diff --git a/lib/vfscore/automount.c b/lib/vfscore/automount.c index 4ab4f0abf..8e78c1f2f 100644 --- a/lib/vfscore/automount.c +++ b/lib/vfscore/automount.c @@ -568,18 +568,19 @@ static int vfscore_extract_volume(const struct vfscore_volume *vv) #endif /* CONFIG_LIBUKCPIO */ /* Handle `mkmp` Unikraft Mount Option */ -static int vfscore_ukopt_mkmp(char *path) +static int vfscore_ukopt_mkmp(const char *path_arg) { + char path[strlen(path_arg) + 1]; char *pos, *prev_pos; int rc; - UK_ASSERT(path); - UK_ASSERT(path[0] == '/'); + UK_ASSERT(path_arg[0] == '/'); - if (path[1] == '\0') { + if (path_arg[1] == '\0') { uk_pr_debug(" mkmp: Called on '/', nothing to pre-create\n"); return 0; } + strcpy(path, path_arg); uk_pr_debug(" mkmp: Ensure mount path \"%s\" exists\n", path); pos = path;