Repository navigation
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
-i@hostresolves to several addresses in onehostent,enter_nwad()created onenwadentry per address but stored the sameargallocation (and the sameprotopointer) in all of them.lsof_destroy()freesnp->argandnp->protofor every entry, so multi-address host names caused a double free. On macOS that abortedlsofbefore its stdio buffers were flushed, which is whyLTsockreported “no client socket by host and port” in CI.Each
nwadnow owns independent copies of its argument and protocol strings, and the caller-owned protocol string is released once after all address entries have been created.Changes
src/arg.c: moved argument allocation into the per-addressnwadconstruction, copyprotoper entry, free partial allocations on failure, and free the caller’sn.protoonce on the success path.tests/case-23-multi-address-hostname.bash: regression test that runslsof -i@<local hostname>when the host name resolves to multiple addresses and fails iflsofis terminated by a signal.Makefile.am: registered the new dialect-neutral test with the autotools test suite.Verification
make -j4-> successbash ./check.bash darwin-> 15/15 test cases passed, 0 failed, 0 skippedbash tests/case-23-multi-address-hostname.bashagainst the pre-fix binary -> fails with status 133 (SIGTRAP); passes against the fixed binarybash -n tests/case-23-multi-address-hostname.bash-> syntax check passedgit diff --check-> no whitespace errorsRisks / Follow-ups
The new test skips when
python3is unavailable or when the machine host name has fewer than two addresses in one family. This host and the macOS CI runner both resolve the host name to multiple addresses, so the regression path is exercised there.This PR is AI Assisted.
Closes #370