aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-07-17 14:17:13 +0100
committerRon Yorston <rmy@pobox.com>2023-07-17 14:17:13 +0100
commit72b97c86c6c1a1902d6dcda3da7c38db13585cdc (patch)
treeb1bad3c388c6af638b3026e33c9b1d900777f621
parentbc0d14ee8eb9720a5df097f5620c4b4c679b6c98 (diff)
downloadbusybox-w32-72b97c86c6c1a1902d6dcda3da7c38db13585cdc.tar.gz
busybox-w32-72b97c86c6c1a1902d6dcda3da7c38db13585cdc.tar.bz2
busybox-w32-72b97c86c6c1a1902d6dcda3da7c38db13585cdc.zip
win32: avoid crashing the console with poll(2)
Commit 8e6991733 (ash: fix 'read' shell built-in (1)) introduced the use of poll(2) in the shell 'read' built-in. When the UTF8 code page is in use this results in the console crashing if a 3 or more byte UTF8 character is entered. The crash is caused by the use of PeekConsoleInputA() which, like ReadConsoleInputA(), is broken. It can be avoided by using PeekConsoleInputW() instead. The number of key events will differ but this doesn't matter in this case as poll(2) effectively runs in a busy loop with a 1ms sleep.
-rw-r--r--win32/poll.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/win32/poll.c b/win32/poll.c
index 4b825c5cc..b39732887 100644
--- a/win32/poll.c
+++ b/win32/poll.c
@@ -234,7 +234,7 @@ windows_compute_revents (HANDLE h, int *p_sought)
234 return 0; 234 return 0;
235 235
236 irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); 236 irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
237 bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); 237 bRet = PeekConsoleInputW (h, irbuffer, nbuffer, &avail);
238 if (!bRet || avail == 0) 238 if (!bRet || avail == 0)
239 return POLLHUP; 239 return POLLHUP;
240 240