lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  9 Aug 2018 10:35:46 +0200
From:   Lukas Czerner <lczerner@...hat.com>
To:     linux-ext4@...r.kernel.org
Cc:     Lukas Czerner <lczerner@...hat.com>
Subject: [PATCH 2/2] e2fsck: remove unnecessary reserve_stdio_fds()

Standard stream are always open, we do not need to "check" it
specifically. Remove reserve_stdio_fds().

This also fixes the file descriptor leak.

Signed-off-by: Lukas Czerner <lczerner@...hat.com>
---
 e2fsck/unix.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 90065b39..268feee0 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -603,25 +603,6 @@ static int e2fsck_update_progress(e2fsck_t ctx, int pass,
 
 #define PATH_SET "PATH=/sbin"
 
-/*
- * Make sure 0,1,2 file descriptors are open, so that we don't open
- * the filesystem using the same file descriptor as stdout or stderr.
- */
-static void reserve_stdio_fds(void)
-{
-	int	fd = 0;
-
-	while (fd <= 2) {
-		fd = open("/dev/null", O_RDWR);
-		if (fd < 0) {
-			fprintf(stderr, _("ERROR: Couldn't open "
-				"/dev/null (%s)\n"),
-				strerror(errno));
-			break;
-		}
-	}
-}
-
 #ifdef HAVE_SIGNAL_H
 static void signal_progress_on(int sig EXT2FS_ATTR((unused)))
 {
@@ -1411,7 +1392,6 @@ int main (int argc, char *argv[])
 			_("while trying to initialize program"));
 		exit(FSCK_ERROR);
 	}
-	reserve_stdio_fds();
 
 	set_up_logging(ctx);
 	if (ctx->logf) {
-- 
2.17.1

Powered by blists - more mailing lists