diegocr / netcat

NetCat for Windows
GNU General Public License v2.0
800 stars 242 forks source link

doexec() - TerminateThread could damage stack and terminate output to client #7

Open ultradumb opened 5 years ago

ultradumb commented 5 years ago

I am suggesting to replace TerminateThread(handle, how) calls in doexec() with WaitForSingleObject(handle, INFINITE), or, maybe, give a small timeout instead of INFINITE. This will allow pipe-to-socket thread functions to finish correctly and deliver data to client (otherwise it is lost). I did it using #define TerminateThread(h, f) WaitForSingleObject(h, INFINITE) just before switch(i) and then #undef-ing it after last break.