From 447ce7436647899cfe03ee154bb2b2789d3a8eac Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 21 Oct 2009 21:01:41 -0600 Subject: [PATCH] areadlinkat: avoid failure on older glibc Acting on /proc/self/-1/name gives ENOTDIR. at-func normally falls back to fchdir, which discovers the real problem of invalid fd and changes to EBADF; but for areadlinkat, it mistakenly short-circuited when FUNC_FAIL was NULL (since 0<=(char*)result is always true). * lib/at-func.c (AT_FUNC_NAME): Check for explicit FUNC_FAIL, rather than mis-comparing 0 against FUNC_RESULT of char*. Signed-off-by: Eric Blake --- ChangeLog | 6 ++++++ lib/at-func.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 806c4a6b4..c08b84415 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-21 Eric Blake + + areadlinkat: avoid failure on older glibc + * lib/at-func.c (AT_FUNC_NAME): Check for explicit FUNC_FAIL, + rather than mis-comparing 0 against FUNC_RESULT of char*. + 2009-10-21 Bruno Haible * modules/stpncpy (License): Relicense under LGPLv2+. diff --git a/lib/at-func.c b/lib/at-func.c index b6aa0fd55..cc7bfc2de 100644 --- a/lib/at-func.c +++ b/lib/at-func.c @@ -84,7 +84,7 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) /* If the syscall succeeds, or if it fails with an unexpected errno value, then return right away. Otherwise, fall through and resort to using save_cwd/restore_cwd. */ - if (0 <= proc_result) + if (FUNC_FAIL != proc_result) return proc_result; if (! EXPECTED_ERRNO (proc_errno)) { -- 2.11.0