diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-05-28 14:15:08 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-05-28 17:18:37 +0100 |
commit | e176ee0b5d8e90b0d3871ee778d290bc3d6abe96 (patch) | |
tree | 194f2eb443a4c78e5320d53c516e68be61982afc /lib/unlinkat.c | |
parent | 2b93f1e2daed6b54c3b9cea74d83186250b84494 (diff) | |
download | gnulib-e176ee0b5d8e90b0d3871ee778d290bc3d6abe96.tar.gz |
unlinkat: handle ignoring of ".." on Darwin 14
* lib/unlinkat.c: unlinkat() has the same bug as unlink()
on Mac OS X 10.10, where it ignores paths with a trailing "..",
so handle in the same manner.
* m4/unlinkat.m4: Comment on this Darwin issue.
* doc/posix-functions/unlink.texi: Update the latest version
where the issue was seen.
* doc/posix-functions/unlinkat.texi: Mention this issue.
Fixes a test failure in test-unlinkat.c.
Diffstat (limited to 'lib/unlinkat.c')
-rw-r--r-- | lib/unlinkat.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/unlinkat.c b/lib/unlinkat.c index 0d89bf9744..af35256fd0 100644 --- a/lib/unlinkat.c +++ b/lib/unlinkat.c @@ -35,9 +35,12 @@ # undef unlinkat -/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris - 9. Solve it in a similar manner to unlink. Hurd has the same - issue. */ +/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris 9. + Hurd has the same issue. + + unlinkat without AT_REMOVEDIR erroneously ignores ".." on Darwin 14. + + Solve these in a similar manner to unlink. */ int rpl_unlinkat (int fd, char const *name, int flag) @@ -78,7 +81,17 @@ rpl_unlinkat (int fd, char const *name, int flag) } } if (!result) - result = unlinkat (fd, name, flag); + { +# if UNLINK_PARENT_BUG + if (len >= 2 && name[len - 1] == '.' && name[len - 2] == '.' + && (len == 2 || ISSLASH (name[len - 3]))) + { + errno = EISDIR; /* could also use EPERM */ + return -1; + } +# endif + result = unlinkat (fd, name, flag); + } return result; } |