tncattach
tncattach copied to clipboard
Fix TCP connection failure when attempting to use a remote host as TNC
This PR fixes an issue where TCP connections to remote hosts were failing due to incorrect memory copying of the host address.
The bug was in the open_tcp function where the memcpy parameters were reversed:
// Old (buggy) code:
memcpy(server->h_addr, &serv_addr.sin_addr.s_addr, server->h_length);
// New (fixed) code:
memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length);
The fix reverses the parameters so that:
- Source:
server->h_addr(the resolved host address) - Destination:
&serv_addr.sin_addr.s_addr(the socket address structure) - Length:
server->h_length(unchanged)
This allows tncattach to properly connect to remote TNCs over TCP as intended.