From f0cf2bc6b0af6e49bad88f0243717fb13b5ef5cc Mon Sep 17 00:00:00 2001 From: ripsaw8080 Date: Tue, 5 Apr 2016 05:40:48 +0000 Subject: [PATCH] Prevent DOS buffered input function from hanging in an infinite loop when redirected input reads a linefeed or reaches EOF. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3977 --- src/dos/dos.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 28e5663b..a421fe07 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -223,6 +223,10 @@ static Bitu DOS_21Handler(void) { free--; for(;;) { DOS_ReadFile(STDIN,&c,&n); + if (n == 0) // End of file + E_Exit("DOS:0x0a:Redirected input reached EOF"); + if (c == 10) // Line feed + continue; if (c == 8) { // Backspace if (read) { //Something to backspace. // STDOUT treats backspace as non-destructive.