summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorKarel Zak2007-01-03 00:28:02 +0100
committerKarel Zak2007-01-04 14:40:00 +0100
commit8271f58d5122e2c8a9a68653767d6ca50692040c (patch)
tree232d2e7749054ce00cd0563cdc118eb9c72b7cc7 /text-utils/more.c
parentexecl() should be use NULL not 0 (diff)
downloadkernel-qcow2-util-linux-8271f58d5122e2c8a9a68653767d6ca50692040c.tar.gz
kernel-qcow2-util-linux-8271f58d5122e2c8a9a68653767d6ca50692040c.tar.xz
kernel-qcow2-util-linux-8271f58d5122e2c8a9a68653767d6ca50692040c.zip
more: fix file descriptor leak
When you view a file with the more command and run a shell, the file descriptor for reading the file is leaked to that process. To test, more any file. Then do !/bin/sh. At the prompt do "ls -l /proc/$$/fd" and you'll see the leaked fd. From: Steve Grubb <sgrubb@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 2b4fceb92..72f2832a7 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -47,6 +47,7 @@
#include <ctype.h>
#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
#include <termios.h>
#include <setjmp.h>
#include <sys/ioctl.h>
@@ -478,6 +479,7 @@ checkf (fs, clearfirst)
}
if (magic(f, fs))
return((FILE *)NULL);
+ fcntl(fileno(f), F_SETFD, FD_CLOEXEC );
c = Getc(f);
*clearfirst = (c == '\f');
Ungetc (c, f);