mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-20 20:50:19 +00:00
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:
@@ -185,6 +185,14 @@ waitline (int sok, char *buf, int bufsize, int use_recv)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
if (bufsize <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (!use_recv && _get_osfhandle (sok) == -1)
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (use_recv)
|
if (use_recv)
|
||||||
|
|||||||
Reference in New Issue
Block a user