[PATCH v2 3/3] daemon: guard NULL REMOTE_PORT in execute() logging
- From
- Sebastien Tardif via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 27, 2026, 18:18 UTC
- Message-ID
- <e3127357169cd8264abca3d9379a0a4071a18b5b.1779905911.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2300.v2.git.git.1779905911.gitgitgadget@gmail.com>
From: Sebastien Tardif <sebtardif@ncf.ca>
REMOTE_ADDR and REMOTE_PORT are both set by the same code path in handle(), so neither should be NULL independently. However, the existing code checks REMOTE_ADDR before the loginfo() call but not REMOTE_PORT. If REMOTE_PORT were unset, NULL would be passed to printf's %s, which is undefined behavior.
Add a fallback string for the NULL case, matching the existing REMOTE_ADDR guard for consistency.
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