ReadFile() on console input can cause buffer overflow
Hi all, I am posting this thread mainly because I can find no other better way to report bugs to Microsoft... :PI found this bug whendebugging a malfunctioningconsole interactive program.ReadFile() system call on console input file handle can overflow the user programdata buffer, when the input text contains mixed ASCII and multibyte characters.For example, when the following code segment is executed:HANDLE hStdin=GetStdHandle(STD_INPUT_HANDLE);BYTE byBuf[128];BYTE padding[128];DWORD dwRet;ReadFile(hStdin,byBuf,128,&dwRet,NULL);If the user input some mixed ASCII and multibyte characters over 128 bytes in length, thebyBuf will receivemore than 128 bytes, overflowinginto padding.I asked a number of people running my test program, and so farconfirmedthis bug on: Windows 7 x64, Windows 2003 x64 / x86, Windows XP SP2 / SP3 x86---PS.The bug seems to do much more damage than crashing a user program. I am using Windows XP SP3. While I was tracing down the bug, stepping through my program, after a couple of runs, the system process csrss.execrashes and starts taking 100% CPU. After reboot, I get to debug the program for another couple of runs, then csrss.execrashes again... and so on...I have a friend who programs and is using Windows 7, he said he will do some testing (debug stepping the program while triggering the overflow), see if Windows 7 crashes as well.
August 19th, 2009 7:59am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics