mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-26 07:31:33 +01:00
path: fix directory special case
This commit is contained in:
parent
e5a0c739d4
commit
2e76b02401
3 changed files with 9 additions and 11 deletions
3
changes/glob_dir
Normal file
3
changes/glob_dir
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
o Minor bugfixes (config):
|
||||||
|
- Fix globbing directories on all platforms. Fixes compilation on musl.
|
||||||
|
Fixes bug 40141; bugfix on 0.4.5.1-alpha.
|
|
@ -611,11 +611,13 @@ tor_glob(const char *pattern)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #40141: workaround for bug in glibc < 2.19 where patterns ending in path
|
// #40141, !249: workaround for glibc bug where patterns ending in path
|
||||||
// separator match files and folders instead of folders only
|
// 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);
|
size_t pattern_len = strlen(pattern);
|
||||||
bool dir_only = has_glob(pattern) &&
|
bool dir_only = pattern_len > 0 && pattern[pattern_len-1] == *PATH_SEPARATOR;
|
||||||
pattern_len > 0 && pattern[pattern_len-1] == *PATH_SEPARATOR;
|
|
||||||
|
|
||||||
result = smartlist_new();
|
result = smartlist_new();
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
@ -4562,15 +4562,8 @@ test_util_glob(void *ptr)
|
||||||
TEST("file1");
|
TEST("file1");
|
||||||
EXPECT(results_test9);
|
EXPECT(results_test9);
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(__darwin__) || \
|
|
||||||
defined(__FreeBSD__) || defined(__NetBSD__) || defined(OpenBSD)
|
|
||||||
TEST("file1"PATH_SEPARATOR);
|
TEST("file1"PATH_SEPARATOR);
|
||||||
EXPECT_EMPTY();
|
EXPECT_EMPTY();
|
||||||
#else
|
|
||||||
const char *results_test10[] = {"file1"};
|
|
||||||
TEST("file1"PATH_SEPARATOR);
|
|
||||||
EXPECT(results_test10);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// test path separator at end - with wildcards and linux path separator
|
// test path separator at end - with wildcards and linux path separator
|
||||||
const char *results_test11[] = {"dir1", "dir2", "forbidden"};
|
const char *results_test11[] = {"dir1", "dir2", "forbidden"};
|
||||||
|
|
Loading…
Add table
Reference in a new issue