alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit be213d544f46e971c1a61a0d2f49f49a134726c1 (patch)
parent a62ba1e9e86bc3882323598a57ff5296329c84da
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat, 24 Apr 2021 00:41:35 -0400

kiosk: Add failure check to /dev/tty opening

ssh-ing with stdin as /dev/null didn't fail on Linux, but it segv'd on
OpenBSD. This patch adds a check that fopen on /dev/tty worked.

Diffstat:
Msrc/kiosk.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/kiosk.c b/src/kiosk.c @@ -3,6 +3,7 @@ #include <string.h> #include <stdlib.h> #include <limits.h> +#include <err.h> int list(void) { DIR *dirp = opendir(MANDIR); @@ -70,6 +71,8 @@ void prompt(int n) { * simple DDOS via < /dev/random */ FILE *tty = fopen("/dev/tty", "r"); + if (tty == NULL) + err(1, "unable to open tty"); char *line = NULL; size_t line_len; ssize_t nread = getline(&line, &line_len, tty);