Loosing byte on telnet connection
My first post - pls be gentle not sure if this is where i should be reporting this... pls direct me elsewhere if this is inappropriate.
I have a docker image (imgA) based on alpine 3.18.2 x64, in it if have both telnetd and sshd running. pls no groans about telnet it is needed.
i have another image (imB) also based on same alpine base which programmatically connects to the telnetd on imgA. On successful connect the login shell runs a process which reads and writes from its stdout.
In effect a process on imgB is connected to a process on imgA via telnet (in binary mode).
I am seeing something really odd and its 100% reproducible.
the process on imgB writes 5 bytes, using strace i monitor the file descriptors on telnetd and i can see the 5 bytes coming in, but the write out to the process which is consuming them is only 4 bytes, i can see that from strace of the downstream process. This causes the downstream process to block reading the 5th expected byte.
strace from the telnetd
/ # strace -e read,write -p 42 -s 999
strace: Process 42 attached
read(4, "\33{!S\0", 2020) = 5
write(5, "\33{!S", 4) = 4
read(5, "\33{!\0\n\3\0\0\0\0", 2020) = 10
write(4, "\33{!\0\n\3\0\0\0\0", 10) = 10
strace from the downstream process, you can see its blocked on a read for the 5th byte which happens to be an 0x00
/ # strace -e read,write -p 42 -s 999
strace: Process 42 attached
read(4, "\33{!S\0", 2020) = 5
write(5, "\33{!S", 4) = 4
read(5, "\33{!\0\n\3\0\0\0\0", 2020) = 10
write(4, "\33{!\0\n\3\0\0\0\0", 10) = 10
I dont think this is anything to do with the telnet protocol itself, any ideas ??
Should also add, if i swap the connection from telnet to ssh then it does not exhibit the issue.