-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Describe the bug
In server mode, when running a command with -e or -c, ncat does not close the socket before executing the child process. Since the parent process exits when the client stops sending data, this can incorrectly cause the client to think more data is incoming.
To Reproduce
ncat -l 1234 -c 'sleep 1; echo response'
echo request | ncat 127.0.0.1 1234When both commands are run in parallel, the server ncat will exit as soon as the client connects, but the client will wait for a second before the socket is closed (with no response data) by sh exiting.
Expected behavior
When a client has stopped sending data, ncat should either:
- Exit the server and fully close the connection without waiting for the child to finish.
- Wait for the child to finish sending output before exiting.
Option 2 is what I would prefer, but is a bigger change than option 1. In both cases though, there is no reason for the child process to keep the socket open.
Version info (please complete the following information):
- OS: Linux 6.8.2
- Output of
ncat --version:Ncat: Version 7.94 ( https://nmap.org/ncat )