mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Fix %include bug with pattern with */ on glibc < 2.19 #40141
Fix bug where %including a pattern ending in */ would include files and folders (instead of folders only) in versions of glibc < 2.19.
This commit is contained in:
parent
f2968c3aac
commit
304ae473ca
4
changes/bug40141
Normal file
4
changes/bug40141
Normal file
@ -0,0 +1,4 @@
|
||||
o Minor bugfixes (configuration):
|
||||
- Fix bug where %including a pattern ending with */ would include files
|
||||
and folders (instead of folders only) in versions of glibc < 2.19.
|
||||
Fixes bug 40141; bugfix on 0.4.5.0-alpha-dev. Patch by Daniel Pinto.
|
@ -598,6 +598,12 @@ 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
|
||||
size_t pattern_len = strlen(pattern);
|
||||
bool dir_only = has_glob(pattern) &&
|
||||
pattern_len > 0 && pattern[pattern_len-1] == *PATH_SEPARATOR;
|
||||
|
||||
result = smartlist_new();
|
||||
size_t i;
|
||||
for (i = 0; i < matches.gl_pathc; i++) {
|
||||
@ -606,7 +612,12 @@ tor_glob(const char *pattern)
|
||||
if (len > 0 && match[len-1] == *PATH_SEPARATOR) {
|
||||
match[len-1] = '\0';
|
||||
}
|
||||
smartlist_add(result, match);
|
||||
|
||||
if (!dir_only || (dir_only && is_dir(file_status(match)))) {
|
||||
smartlist_add(result, match);
|
||||
} else {
|
||||
tor_free(match);
|
||||
}
|
||||
}
|
||||
globfree(&matches);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user