[PATCH 3/3] daemon: guard NULL REMOTE_PORT in execute() logging
- From
- Sebastien Tardif via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 14, 2026, 15:46 UTC
- Message-ID
- <1b2f9d1a07b6e93cc9e137b4fdf6e8f5fee9214e.1778773592.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2300.git.git.1778773592.gitgitgadget@gmail.com>
From: Sebastien Tardif <sebtardif@ncf.ca>
The REMOTE_PORT environment variable is used in a format string without a NULL check, while REMOTE_ADDR is checked. If REMOTE_PORT is unset, NULL is passed to printf's %s, which is undefined behavior.
Add a fallback string for the NULL case.
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca> --- daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon.c b/daemon.c index 103c08d868..78cca8673f 100644 --- a/daemon.c +++ b/daemon.c @@ -753,7 +753,7 @@ static int execute(void) struct strvec env = STRVEC_INIT; if (addr) - loginfo("Connection from %s:%s", addr, port); + loginfo("Connection from %s:%s", addr, port ? port : "?"); set_keep_alive(0); alarm(init_timeout ? init_timeout : timeout);
-- gitgitgadget