X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Funlinkat.c;h=af35256fd086552b9f9f5ac142128c5206e1b82a;hb=d30babc23b4f25be970ada2e63a50220a3672281;hp=242ad493650f75a3f2d0156db2595760ba7026db;hpb=4aa85f09e755fc827cd5ab6225f20c83cd42245d;p=debian%2Ftar diff --git a/gnu/unlinkat.c b/gnu/unlinkat.c index 242ad493..af35256f 100644 --- a/gnu/unlinkat.c +++ b/gnu/unlinkat.c @@ -1,8 +1,6 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Work around unlinkat bugs on Solaris 9 and Hurd. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,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) @@ -80,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; }