Added defensive input validation in waitline() to return -1 when bufsize <= 0, preventing invalid buffer handling paths.

Added a Windows-specific guard in waitline() that checks _get_osfhandle(sok) before calling read() in non-socket mode; if the CRT file descriptor is invalid, it now fails gracefully with -1 instead of hitting the debug CRT assertion you reported.
This commit is contained in:
2026-02-16 01:09:16 -07:00
parent 2bfd96c9e0
commit 6f97c060b3

View File

@@ -185,6 +185,14 @@ waitline (int sok, char *buf, int bufsize, int use_recv)
{
int i = 0;
if (bufsize <= 0)
return -1;
#ifdef WIN32
if (!use_recv && _get_osfhandle (sok) == -1)
return -1;
#endif
while (1)
{
if (use_recv)