From 9bdd0f8cff8a6c5f1fa61dfe4e6a4ed297248d80 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 4 Dec 2019 15:25:53 -0500 Subject: target should only be the basename if the target is a directory --- ln.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ln.c b/ln.c index ab73b42..2d48652 100644 --- a/ln.c +++ b/ln.c @@ -25,6 +25,7 @@ #define _POSIX_C_SOURCE 200809L #include #include +#include #include #include #include @@ -39,8 +40,10 @@ enum { SYMBOLIC = 1 << 0, FORCE = 1 << 1 }; static int ln(const char *path, int dirfd, const char *target, int lnflag, int atflag) { + char base[strlen(path) + 1]; if (!target) { - target = path; + strcpy(base, path); + target = basename(base); } struct stat st; -- cgit v1.2.1