diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-25 23:39:04 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-25 23:41:55 +0200 |
commit | ab063437ce4271d31c150a19390c6d6b18aedf04 (patch) | |
tree | c5a6c511a9e83d66c899f23737768b5c7687ab48 /lib/fstree | |
parent | ba82a3812d39acf6c865478f72d7e68838c14f69 (diff) |
Make sure symlink in fstree_mknode is always set when creating a symlink
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r-- | lib/fstree/mknode.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/fstree/mknode.c b/lib/fstree/mknode.c index ea0d0aa..c6572fe 100644 --- a/lib/fstree/mknode.c +++ b/lib/fstree/mknode.c @@ -5,6 +5,7 @@ #include <string.h> #include <stdlib.h> +#include <errno.h> tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name, size_t name_len, const char *extra, @@ -16,6 +17,10 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name, switch (sb->st_mode & S_IFMT) { case S_IFLNK: + if (extra == NULL) { + errno = EINVAL; + return NULL; + } size += strlen(extra) + 1; break; case S_IFDIR: @@ -67,7 +72,8 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name, case S_IFLNK: n->mode = S_IFLNK | 0777; n->data.slink_target = (char *)n->payload; - strcpy(n->data.slink_target, extra); + if (extra != NULL) + strcpy(n->data.slink_target, extra); break; case S_IFBLK: case S_IFCHR: |