confd: fix double free of container hostname #716
Merged
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.
Description
Fix a double free in the memory minefield surrounding container hostname provisioning. The hostnamefmt() function already does free() on success.
This caused all sorts of mayhem when working with multiple containers. However it mainly manifested itself by some containers not starting due to there activation script being polluted with gibberish name data. Your symptom might be different..
Example of polluted activation script
container --hostname foobar --net veth0k -r always \ create ^S@`M-}^G docker://ghcr.io/kernelkit/curios:edge
Side note
I haven't looked into it but is it really legit to free memory returned from the various lydx_ functions used here?
It seems to work as intended but it looks risky at a glance.
Checklist
Tick relevant boxes, this PR is-a or has-a: