X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fopendir-safer.c;h=98272f4bc1e8830e6ea4337402db0fa3e3d0c32d;hb=daa269958ad8d50ef8154ccb65e58acaf7a6dd99;hp=3d8007ab33b794571ae39169ef5c9f6363c558bf;hpb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;p=debian%2Ftar diff --git a/gnu/opendir-safer.c b/gnu/opendir-safer.c index 3d8007ab..98272f4b 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-2011 Free Software Foundation, Inc. + Copyright (C) 2009-2013 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;