]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Do not copy oldpath in symlink
authorMarc Rittinghaus <marc.rittinghaus@unikraft.io>
Tue, 25 Apr 2023 10:19:05 +0000 (12:19 +0200)
committerUnikraft <monkey@unikraft.io>
Sun, 7 May 2023 13:02:06 +0000 (13:02 +0000)
With the changes to the vnode ops definitions the symlink operation
takes a constant string. We can thus just pass the input string on
without having to copy it.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

lib/vfscore/syscalls.c

index 45acb841ec7b04cc41fcb67c5339a013f02f93ac..12946cc30a18efe2aefaa3fafa466481fe2e5667 100644 (file)
@@ -883,7 +883,6 @@ sys_symlink(const char *oldpath, const char *newpath)
 {
        struct task     *t = main_task;
        int             error;
-       char            op[PATH_MAX];
        char            np[PATH_MAX];
        struct dentry   *newdp;
        struct dentry   *newdirdp;
@@ -922,14 +921,7 @@ sys_symlink(const char *oldpath, const char *newpath)
                goto out;
        }
 
-       /* oldpath may not be const char * to VOP_SYMLINK - need to copy */
-       size_t tocopy;
-       tocopy = strlcpy(op, oldpath, PATH_MAX);
-       if (tocopy >= PATH_MAX - 1) {
-               error = ENAMETOOLONG;
-               goto out;
-       }
-       error = VOP_SYMLINK(newdirdp->d_vnode, name, op);
+       error = VOP_SYMLINK(newdirdp->d_vnode, name, oldpath);
 
 out:
        if (newdirdp != NULL) {