aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2020-09-09 22:08:54 +0000
committerDavid Goulet <dgoulet@torproject.org>2020-09-10 10:51:57 -0400
commit1c4b140427aeb36d80475e92fe57154fcc8abcf3 (patch)
tree068b66118c83ee5503bac61d6a34c78edd57bb61 /src/lib
parent12c758312651c09eb68e9f4e04a7fd3ad9c3a811 (diff)
downloadtor-1c4b140427aeb36d80475e92fe57154fcc8abcf3.tar.gz
tor-1c4b140427aeb36d80475e92fe57154fcc8abcf3.zip
Check if glob() is available at build-time.
This patch disables the glob() support in the path library if glob() is unavailable at build-time. This currently happens with the Android NDK used for Tor Browser. See: https://bugs.torproject.org/tpo/core/tor/40114
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fs/path.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/fs/path.c b/src/lib/fs/path.c
index f03cecf52d..1a15969419 100644
--- a/src/lib/fs/path.c
+++ b/src/lib/fs/path.c
@@ -532,7 +532,7 @@ unglob_win32(const char *pattern, int prev_sep, int next_sep)
tor_free(path_until_glob);
return result;
}
-#else /* !defined(_WIN32) */
+#elif HAVE_GLOB
/** Same as opendir but calls sandbox_intern_string before */
static DIR *
prot_opendir(const char *name)
@@ -559,7 +559,7 @@ wrap_closedir(void *arg)
{
closedir(arg);
}
-#endif /* defined(_WIN32) */
+#endif /* defined(HAVE_GLOB) */
/** Return a new list containing the paths that match the pattern
* <b>pattern</b>. Return NULL on error. On POSIX systems, errno is set by the
@@ -568,14 +568,15 @@ wrap_closedir(void *arg)
struct smartlist_t *
tor_glob(const char *pattern)
{
- smartlist_t *result;
+ smartlist_t *result = NULL;
+
#ifdef _WIN32
// PathMatchSpec does not support forward slashes, change them to backslashes
char *pattern_normalized = tor_strdup(pattern);
tor_strreplacechar(pattern_normalized, '/', *PATH_SEPARATOR);
result = get_glob_paths(pattern_normalized, unglob_win32, true);
tor_free(pattern_normalized);
-#else /* !(defined(_WIN32)) */
+#elif HAVE_GLOB /* !(defined(_WIN32)) */
glob_t matches;
int flags = GLOB_ERR | GLOB_NOSORT;
#ifdef GLOB_ALTDIRFUNC
@@ -608,7 +609,11 @@ tor_glob(const char *pattern)
smartlist_add(result, match);
}
globfree(&matches);
-#endif /* defined(_WIN32) */
+#else
+ (void)pattern;
+ return result;
+#endif /* !defined(HAVE_GLOB) */
+
return result;
}