]> granicus.if.org Git - strace/commitdiff
strace.c: check return code of never failing fcntl call
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 2 May 2018 18:59:32 +0000 (20:59 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 3 May 2018 00:09:53 +0000 (00:09 +0000)
Because the kernel cannot be trusted.

* strace.c (set_cloexec_flag): Call perror_msg_and_die if fcntl(F_SETFD)
has failed.

strace.c

index 4f41a25960f320fcf0fb96fb55e133db8feec6b9..3ea889f45095e83c482e4334bff86d9e34e18528 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -421,7 +421,8 @@ set_cloexec_flag(int fd)
        if (flags == newflags)
                return;
 
-       fcntl(fd, F_SETFD, newflags); /* never fails */
+       if (fcntl(fd, F_SETFD, newflags)) /* never fails */
+               perror_msg_and_die("fcntl(%d, F_SETFD, %#x)", fd, newflags);
 }
 
 static void