Repository navigation
libc/netdb: Keep *ahost intact on failure and preserve errno in rexec_af. - #22963
Open
yashgoyal0110 wants to merge 1 commit into
Open
yashgoyal0110 wants to merge 1 commit into
yashgoyal0110 wants to merge 1 commit into
Conversation
…_af. Validate *ahost != NULL in rexec_af(), store the duplicated canonical hostname into *ahost only after the connection and protocol writes succeed so *ahost is not left pointing to freed memory on error, and preserve errno across close() in the error path. Fixes: apache#22958 Assisted-by: GPT-5.4 Signed-off-by: YASH GOYAL <yg364550@gmail.com>
yashgoyal0110
requested review from
jerpelea and
pkarashchenko
as code owners
December 6, 2026 10:32
|
xiaoxiang781216
approved these changes
Dec 6, 2026
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
In
libs/libc/netdb/lib_rexec.c,rexec_af()previously assigned*ahost = strdup(res->ai_canonname)beforesocket(),connect(), and the initialwrite()calls completed, and freed*ahoston the error path without restoring the caller's pointer.Hold the duplicated canonical name in a local pointer and assign
*ahostonly after the connection and protocol writes succeed, check!*ahoston entry, formatinportas unsigneduint16_t, and saveerrnoaroundclose(sock)on failure.Fixes #22958
Impact
*ahostis no longer left pointing to freed memory whenrexec()/rexec_af()fails, anderrnoreflects the failing socket operation.*ahostpointer after failed connection attempts.Testing
Tested
rexec_af()failure paths (*ahost == NULL,socket()failure,connect()failure) and verified*ahostanderrnoare preserved.