Le dimanche 28 septembre 2014, 11:25:44 Reinhard Tartler a écrit : > From: Michael Niedermayer <[email protected]> > > If we can make use of O_CLOEXEC, we don't need the fcntl() call. On > systems that don't support O_CLOEXEC, try to reconfigure the file > descriptor using the fcntl() API, but ignore failures. > > Fixes CID1087079 > Signed-off-by: Reinhard Tartler <[email protected]> > --- > libavutil/file_open.c | 8 +++++--- > libavutil/internal.h | 5 +++++ > 2 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/libavutil/file_open.c b/libavutil/file_open.c > index 765eb60..42ecafd 100644 > --- a/libavutil/file_open.c > +++ b/libavutil/file_open.c > @@ -19,6 +19,7 @@ > #include "config.h" > #include "internal.h" > #include "mem.h" > +#include "log.h" > #include <stdarg.h> > #include <fcntl.h> > #include <sys/stat.h> > @@ -84,9 +85,10 @@ int avpriv_open(const char *filename, int flags, ...) > #endif > > fd = open(filename, flags, mode); > -#if HAVE_FCNTL > - if (fd != -1) > - fcntl(fd, F_SETFD, FD_CLOEXEC); > + > +#if !defined O_CLOEXEC && defined FD_CLOEXEC && defined HAVE_FCNTL > + /* This is a weird case, cf. https://patches.libav.org/patch/54004/ */ > + (void)fcntl(fd, F_SETFD, FD_CLOEXEC);
Only thing this patch seems to do is, clobber the error number from open() with EBADF when an error occurs. That seems worse in all respects to the current code. And it won't even fix the Coverity report if that's what you're after. -- Rémi Denis-Courmont http://www.remlab.net/ _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
