[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: areadlinkat
From: |
Eric Blake |
Subject: |
Re: areadlinkat |
Date: |
Wed, 21 Oct 2009 21:33:46 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Eric Blake on 10/7/2009 11:00 AM:
> Eric Blake (4):
> areadlink, areadlink-with-size: add tests
> areadlinkat: new module
> 2009-10-07 Eric Blake <address@hidden>
>
> + areadlinkat: new module
> + * lib/at-func.c (FUNC_FAIL): New define.
> + (AT_FUNC_NAME, VALIDATE_FLAG): Use it rather than raw -1.
Oops - I missed one instance relating to FUNC_FAIL. test-areadlinkat was
failing on older Linux, because /proc/self/fd/-1/name gave ENOENT rather
than EBADF. But since 0 <= char* was always true, the fallback code that
converts ENOENT into the correct error was never triggered.
areadlinkat-with-size was the only other impacted client of at-func.c.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkrf0poACgkQ84KuGfSFAYDy+wCgvKLsGfIRa/kU0No546KlutU0
BkQAn2NhvjOtHe3k16n+P44a/kZf7myN
=FWLv
-----END PGP SIGNATURE-----
>From e35809901f94acb04ccc325d9ef1b0eed6cedd81 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
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, not EBADF. at-func
normally fell back to fchdir, which discovered the real problem
of invalid fd, but 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 <address@hidden>
---
ChangeLog | 6 ++++++
lib/at-func.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 806c4a6..c08b844 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-10-21 Eric Blake <address@hidden>
+
+ 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 <address@hidden>
* modules/stpncpy (License): Relicense under LGPLv2+.
diff --git a/lib/at-func.c b/lib/at-func.c
index b6aa0fd..cc7bfc2 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))
{
--
1.6.5.rc1
Message not available
Message not available