develooper Front page | perl.perl5.porters | Postings from April 2014

[perl #121745] [PATCH] Coverity: not checking return values of system/library calls (mainly fcntl)

Thread Previous
From:
Tony Cook via RT
Date:
April 28, 2014 03:48
Subject:
[perl #121745] [PATCH] Coverity: not checking return values of system/library calls (mainly fcntl)
Message ID:
rt-4.0.18-23132-1398656911-1429.121745-15-0@perl.org
On Sat Apr 26 13:01:39 2014, jhi wrote:
> Attached.

--- a/doio.c
+++ b/doio.c
@@ -755,7 +755,8 @@ S_openn_cleanup(pTHX_ GV *gv, IO *io, PerlIO *fp, char *mode, const char *oname,
 #if defined(HAS_FCNTL) && defined(F_SETFD)
     if (fd >= 0) {
 	dSAVE_ERRNO;
-	fcntl(fd,F_SETFD,fd > PL_maxsysfd); /* can change errno */
+	if (fcntl(fd,F_SETFD,fd > PL_maxsysfd) < 0) /* can change errno */
+            goto say_false;
 	RESTORE_ERRNO;
     }
 #endif

Should this PerlIO_close() the handle before C< goto say_false > ?

I suspect we should be using FD_CLOEXEC in a few other places, but that's not made any worse by your patch.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=121745

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About