From 825c1a1141a5724b980d0c1af7fe138ff7d10ae4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 14 Jun 2010 11:48:06 +0000 Subject: 28010: use getcwd() as fallback --- configure.ac | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 262fe5d14..a93eb5115 100644 --- a/configure.ac +++ b/configure.ac @@ -1170,7 +1170,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ regcomp regexec regerror regfree \ gdbm_open getxattr \ realpath canonicalize_file_name \ - symlink) + symlink getcwd) AC_FUNC_STRCOLL if test x$enable_cap = xyes; then @@ -1898,6 +1898,34 @@ if test x$zsh_cv_use_getcwd = xyes; then AC_DEFINE(USE_GETCWD) fi +dnl GNU getcwd() can allocate as much space as necessary for a +dnl directory name, preventing guessing games. +AH_TEMPLATE([GETCWD_CALLS_MALLOC], +[Define to 1 if getcwd() calls malloc to allocate memory.]) +if test x$ac_cv_func_getcwd = xyes; then + AC_CACHE_CHECK(whether getcwd calls malloc to allocate memory, + zsh_cv_getcwd_malloc, + [AC_TRY_RUN([ +#include +#include +int main() { + char buf[1024], *ptr1, *ptr2; + ptr1 = getcwd(buf, 1024); + ptr2 = getcwd(NULL, 0); + if (ptr1 && ptr2 && !strcmp(ptr1, ptr2)) { + return 0; + } + return 1; +} +], + zsh_cv_getcwd_malloc=yes, + zsh_cv_getcwd_malloc=no, + zsh_cv_getcwd_malloc=no)]) + if test x$zsh_cv_getcwd_malloc = xyes; then + AC_DEFINE(GETCWD_CALLS_MALLOC) + fi +fi + dnl CHECK FOR setproctitle() FOR jobs -Z / ARGV0 AH_TEMPLATE([HAVE_SETPROCTITLE], [Define to 1 if the system supports `setproctitle' to change process name]) -- cgit 1.4.1