X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fopendir-safer.c;h=9bbcda85a35bdd025311e7250df643897dc0e408;hb=d30babc23b4f25be970ada2e63a50220a3672281;hp=f0a1b4c146d648062d463abe336e92d28cbebc55;hpb=22f1eb8bc17e5be72dd23d42d6aaa60196ac22e6;p=debian%2Ftar diff --git a/gnu/opendir-safer.c b/gnu/opendir-safer.c index f0a1b4c1..9bbcda85 100644 --- a/gnu/opendir-safer.c +++ b/gnu/opendir-safer.c @@ -1,8 +1,6 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Invoke opendir, but avoid some glitches. - Copyright (C) 2009, 2010 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 @@ -52,10 +50,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;