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

Fix TCP connection failure when attempting to use a remote host as TNC #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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