X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Funlinkat.c;h=c89bc9c2d9a141feedb6a1004252a7796c5492d7;hb=547f1057e84f61003a0db4049df3f90725187f0b;hp=008192e6d3fa8f72971d21b070b1c36e571be5fc;hpb=dc0ab95dbae38577efebe2283fc9b76e92ef4233;p=debian%2Fgzip diff --git a/lib/unlinkat.c b/lib/unlinkat.c index 008192e..c89bc9c 100644 --- a/lib/unlinkat.c +++ b/lib/unlinkat.c @@ -1,6 +1,6 @@ -/* Work around unlinkat bugs on Solaris 9. +/* Work around unlinkat bugs on Solaris 9 and Hurd. - Copyright (C) 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2009-2016 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 @@ -26,14 +26,21 @@ #include #include +#include + +#include "dosname.h" #include "openat.h" #if HAVE_UNLINKAT # undef unlinkat -/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris - 9. Solve it in a similar manner to unlink. */ +/* 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) @@ -74,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; }