X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fopendir-safer.c;h=e562751d19d25f01f7425d58e30236dfb3b95a89;hb=4aa85f09e755fc827cd5ab6225f20c83cd42245d;hp=f0a1b4c146d648062d463abe336e92d28cbebc55;hpb=22f1eb8bc17e5be72dd23d42d6aaa60196ac22e6;p=debian%2Ftar diff --git a/gnu/opendir-safer.c b/gnu/opendir-safer.c index f0a1b4c1..e562751d 100644 --- a/gnu/opendir-safer.c +++ b/gnu/opendir-safer.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Invoke opendir, but avoid some glitches. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2014 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 @@ -52,10 +52,18 @@ opendir_safer (char const *name) int e; #if HAVE_FDOPENDIR || GNULIB_FDOPENDIR int f = dup_safer (fd); - newdp = fdopendir (f); - e = errno; - if (! newdp) - close (f); + if (f < 0) + { + e = errno; + newdp = NULL; + } + else + { + newdp = fdopendir (f); + e = errno; + if (! newdp) + close (f); + } #else /* !FDOPENDIR */ newdp = opendir_safer (name); e = errno;