Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL packets are not written to stdout if stdout is pipe #2788

Open
u19809 opened this issue Feb 27, 2024 · 0 comments
Open

SSL packets are not written to stdout if stdout is pipe #2788

u19809 opened this issue Feb 27, 2024 · 0 comments
Labels

Comments

@u19809
Copy link

u19809 commented Feb 27, 2024

Describe the bug

We use ncat as a process between a data sync and a data source where sync and source are using linux pipes to write and read data from ncat. our main application uses 'pipe'-s to fork ncat and writes/reads data to and from the relevant pipes.

What we see happening when running the system with strace, that ncat receives a packet from the host it connected to of - say - 15K and that it writes 8K to the stdout (which is the pipe to the sync). Then it does a select on stdin and the socket it opened to the host but does never come back to write the rest of the 15K packet to the stdout.

The 8K corresponds to the DEFAULT_TCP_BUF_LEN constant defined in ncat.h and which determines the buffering IO size

This only happens when using SSL to connect to the host and NOT if you use regular sockets.

We think that this is due to the fact that ssl internally buffers the read bytes (all 15K is read in one recvfrom) and that ssl has some bytes in the internal buffer, whereas the regular socket uses read/recv directly and hence can use the select to know if more data is available. Regular sockets read the 15K in 2 separate packets, one 8K and one 6-ishK

To Reproduce
we use the following command line options "--ssl localhost someport --no-shutdown"

Expected behavior
We would expect the rest of the SSL data to be written to stdout/pipe

Version info (please complete the following information):

  • OS: redhat 8
  • Output of ncat --version: 7.92
@u19809 u19809 added the Ncat label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant