netcat: Fix a buffer overflow
The buffer doesn't have the space for the terminating NUL. Fix it by replacing it with fwrite, as there seems to be little reason to use fprintf and NUL-terminated string in the first place.
This commit is contained in:
parent
3b21cd9ceb
commit
87c876c1cc
@ -99,8 +99,7 @@ int netcat_server(int argc, char * argv[])
|
||||
while (0 < avail)
|
||||
{
|
||||
avail = recv(conn, buf, capacity, 0);
|
||||
buf[avail] = 0;
|
||||
fprintf(fout, "%s", buf);
|
||||
fwrite(buf, avail, 1, fout);
|
||||
int status = fflush(fout);
|
||||
if (0 != status)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user