mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
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
This commit is contained in:
parent
12c7583126
commit
1c4b140427
@ -845,6 +845,8 @@ fi
|
||||
AM_CONDITIONAL(BUILD_READPASSPHRASE_C,
|
||||
test "x$ac_cv_func_readpassphrase" = "xno" && test "$bwin32" = "false")
|
||||
|
||||
AC_CHECK_FUNCS(glob)
|
||||
|
||||
AC_MSG_CHECKING([whether free(NULL) works])
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM([
|
||||
#include <stdlib.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -4440,6 +4440,7 @@ test_util_glob(void *ptr)
|
||||
{
|
||||
(void)ptr;
|
||||
|
||||
#ifdef HAVE_GLOB
|
||||
smartlist_t *results = NULL;
|
||||
int r, i;
|
||||
char *dir1 = NULL, *dir2 = NULL, *forbidden = NULL, *dirname = NULL;
|
||||
@ -4656,6 +4657,11 @@ test_util_glob(void *ptr)
|
||||
SMARTLIST_FOREACH(results, char *, f, tor_free(f));
|
||||
smartlist_free(results);
|
||||
}
|
||||
#else
|
||||
tt_skip();
|
||||
done:
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4663,6 +4669,7 @@ test_util_get_glob_opened_files(void *ptr)
|
||||
{
|
||||
(void)ptr;
|
||||
|
||||
#ifdef HAVE_GLOB
|
||||
smartlist_t *results = NULL;
|
||||
int r, i;
|
||||
char *dir1 = NULL, *dir2 = NULL, *forbidden = NULL, *dirname = NULL;
|
||||
@ -4843,6 +4850,11 @@ test_util_get_glob_opened_files(void *ptr)
|
||||
SMARTLIST_FOREACH(results, char *, f, tor_free(f));
|
||||
smartlist_free(results);
|
||||
}
|
||||
#else
|
||||
tt_skip();
|
||||
done:
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user