From 311f4bd0d9de320f3d6466b384360ab45c84bd47 Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 19 Jul 2023 13:26:20 +0000 Subject: [PATCH] Partially fix interactive mode in patch If ask() can't open /dev/tty for reading, it assumes the default answer and carries on. Add missing unveil, so that ask() waits for an answer. This isn't a full fix since it won't allow giving paths outside the tree rooted at the current directory, but that's expected by the recent change. Questions are only asked outside of force or batch mode. fix suggested by op and semarie ok deraadt florian --- usr.bin/patch/patch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 67da2bd23b3..322a024cf2c 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.73 2023/07/15 10:42:54 florian Exp $ */ +/* $OpenBSD: patch.c,v 1.74 2023/07/19 13:26:20 tb Exp $ */ /* * patch - a program to apply diffs to original files @@ -223,6 +223,11 @@ main(int argc, char *argv[]) perror("unveil"); my_exit(2); } + if (!force && !batch) + if (unveil(_PATH_TTY, "r") == -1) { + perror("unveil"); + my_exit(2); + } if (unveil(".", "rwc") == -1) { perror("unveil"); my_exit(2); -- 2.20.1