Skip to content

Conversation

@rlaneth
Copy link

@rlaneth rlaneth commented Nov 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant