aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-08 15:03:13 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-08 15:03:13 +0100
commit8721298b21f2d645f35906141dd66bee3271d2ed (patch)
treeaf66c79454327f4680d759a0e55c77fd5c8b99a5
parent3adb015fe0741b6b3143be4e96599a3b013b1589 (diff)
downloadpseudo-8721298b21f2d645f35906141dd66bee3271d2ed.tar.gz
pseudo-8721298b21f2d645f35906141dd66bee3271d2ed.tar.bz2
pseudo-8721298b21f2d645f35906141dd66bee3271d2ed.zip
pseudo_client: Fix dirfd handling with empty paths
We're seeing systems in the wild (e.g. ubuntu 20.04) which call with a dirfd set to the full filename and path set to "". Since this seems to be expected to work, handle it accordingly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--pseudo_client.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pseudo_client.c b/pseudo_client.c
index 4aa3522..116d926 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -1469,8 +1469,12 @@ base_path(int dirfd, const char *path, int leave_last) {
if (!path)
return NULL;
- if (!*path)
+
+ if (!*path) {
+ if (dirfd != -1 && dirfd != AT_FDCWD)
+ return fd_path(dirfd);
return "";
+ }
if (path[0] != '/') {
if (dirfd != -1 && dirfd != AT_FDCWD) {