From 5922a236d0ce7fcf911fce6ff7a52b11ddcf2142 Mon Sep 17 00:00:00 2001 From: Henry Stern Date: Fri, 11 Sep 2015 08:06:24 -0300 Subject: Don't resolve broken symbolic links. This commit offers an alternative behaviour of not resolving broken symbolic links in case returning ENOENT is undesirable behaviour. --- src/bindfs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/bindfs.c b/src/bindfs.c index dcb7a6f..3ee8ac5 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -248,6 +248,8 @@ static int is_mirrored_user(uid_t uid) static char * process_path(const char *path) { + char * res; + if (path == NULL) { /* possible? */ errno = EINVAL; return NULL; @@ -259,10 +261,13 @@ static char * process_path(const char *path) if (*path == '\0') path = "."; - if (settings.resolve_symlinks) - return realpath(path, NULL); - else - return strdup(path); + if (settings.resolve_symlinks) { + res = realpath(path, NULL); + if (res) + return res; + } + + return strdup(path); } static int getattr_common(const char *procpath, struct stat *stbuf) -- cgit v1.2.3