summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorHello71 <alex_y_xu@yahoo.ca>2021-01-09 19:16:20 +0000
committerAlexander Færøy <ahf@torproject.org>2021-01-22 13:19:52 +0000
commit2e76b024015cb1f0263bfe53746a759b7d255a20 (patch)
tree3121c7a60aefd06daedb50a1e35d3501ad7d06a1 /src/lib
parente5a0c739d4865b300e904d45c413d5c8f0da304c (diff)
downloadtor-2e76b024015cb1f0263bfe53746a759b7d255a20.tar.gz
tor-2e76b024015cb1f0263bfe53746a759b7d255a20.zip
path: fix directory special case
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fs/path.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/fs/path.c b/src/lib/fs/path.c
index c2fdddb9db..39794cb84e 100644
--- a/src/lib/fs/path.c
+++ b/src/lib/fs/path.c
@@ -611,11 +611,13 @@ tor_glob(const char *pattern)
return NULL;
}
- // #40141: workaround for bug in glibc < 2.19 where patterns ending in path
- // separator match files and folders instead of folders only
+ // #40141, !249: workaround for glibc bug where patterns ending in path
+ // separator match files and folders instead of folders only.
+ // this could be in #ifdef __GLIBC__ but: 1. it might affect other libcs too,
+ // and 2. it doesn't cost much to stat each match again since libc is already
+ // supposed to do it (otherwise the file may be on slow NFS or something)
size_t pattern_len = strlen(pattern);
- bool dir_only = has_glob(pattern) &&
- pattern_len > 0 && pattern[pattern_len-1] == *PATH_SEPARATOR;
+ bool dir_only = pattern_len > 0 && pattern[pattern_len-1] == *PATH_SEPARATOR;
result = smartlist_new();
size_t i;