[PATCH 15/31] more: check open(3) return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/more.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index 0c1bc96..2813ce7 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1082,7 +1082,10 @@ static void execute(struct more_control *ctl, char *filename, char *cmd, ...)
 	if (id == 0) {
 		if (!isatty(STDIN_FILENO)) {
 			close(STDIN_FILENO);
-			open("/dev/tty", 0);
+			if (open("/dev/tty", 0) < 0) {
+				fprintf(stderr, _("cannot open %s"), "/dev/tty\n");
+				goto err;
+			}
 		}
 
 		va_start(argp, cmd);
@@ -1125,6 +1128,7 @@ static void execute(struct more_control *ctl, char *filename, char *cmd, ...)
 		fputs(_("can't fork\n"), stderr);
 	set_tty(ctl);
 	puts("------------------------");
+err:
 	prompt(ctl, filename);
 }
 
-- 
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux