NetBSD-Bugs archive

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

bin/54885: fish(8) infinite loop

>Number:         54885
>Category:       bin
>Synopsis:       fish(8) infinite-loops with EOF to the instructions? question
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 23 05:35:00 +0000 2020
>Originator:     Mouse
>Release:        NetBSD 8.0, 5.2, 4.0.1, and 1.4T
System: NetBSD Stone.Rodents-Montreal.ORG 4.0.1 NetBSD 4.0.1 (GEN401) #0: Fri May 24 21:39:53 EDT 2019 mouse%Stone.Rodents-Montreal.ORG@localhost:/home/mouse/kbuild/GEN401 i386
Architecture: i386
Machine: i386
(The above are from the machine I'm running send-pr on.  I see this
issue on an 8.0 machine, a 5.2 machine, and a 1.4T machine as well, but
this is the one with mail working well on it.)
	EOF to the "want instructions?" question makes fish(8)
	infinite-loop.  (Also, typing return without answering the
	question "does nothing"; you need a second return to proceed in
	that case.)
	Start fish(8).  At the

	Would you like instructions (y or n)? 

	prompt, type your EOF character.  Watch fish infinite-loop.

	For the other issue, enter a zero-length line there.  Notice
	fish does not proceed until you give it _another_ newline.
	This works for me on one of my 5.2 machines:

diff --git a/games/fish/fish.c b/games/fish/fish.c
index becedf6..2ea86f8 100644
--- a/games/fish/fish.c
+++ b/games/fish/fish.c
@@ -440,7 +440,14 @@ instructions(void)
 	(void)printf("Would you like instructions (y or n)? ");
 	input = getchar();
-	while (getchar() != '\n');
+ if (input != '\n')
+  { while (1)
+     { int c;
+       c = getchar();
+       if (c == '\n') break;
+       if (c == EOF) exit(0);
+     }
+  }
 	if (input != 'y')

Home | Main Index | Thread Index | Old Index