summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-12-04 15:25:53 -0500
committerJakob Kaivo <jkk@ung.org>2019-12-04 15:25:53 -0500
commit9bdd0f8cff8a6c5f1fa61dfe4e6a4ed297248d80 (patch)
tree889fc95e8c6fe2156c88f06363c632699d13d397
parent69b820fa2c271f1eafaf692a0a8e57e22e83daa3 (diff)
target should only be the basename if the target is a directoryHEADmaster
-rw-r--r--ln.c5
1 files changed, 4 insertions, 1 deletions
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 <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
@@ -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;