From 773febc60c8a09507f5c4d66d9f576afe5a199be Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 30 Jul 2026 14:43:03 -0700 Subject: [PATCH] wolfsshd: compare the terminated copy in GetConfigInt - The zero check ran WSTRCMP() on the caller's buffer, which is a length-bounded slice of the config line and not NUL terminated, so it read past inSz and rejected valid "0" values whose slice had trailing text. - Compare num, the NUL-terminated copy that atol() was given. Issue: F-7213 --- apps/wolfsshd/configuration.c | 2 +- apps/wolfsshd/test/test_configuration.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/wolfsshd/configuration.c b/apps/wolfsshd/configuration.c index 3a177f3b..61ce9b1c 100644 --- a/apps/wolfsshd/configuration.c +++ b/apps/wolfsshd/configuration.c @@ -151,7 +151,7 @@ static long GetConfigInt(const char* in, int inSz, int isTime, void* heap) WMEMCPY(num, in, sz); num[sz] = '\0'; ret = atol(num); - if (ret == 0 && WSTRCMP(in, "0") != 0) { + if (ret == 0 && WSTRCMP(num, "0") != 0) { ret = WS_BAD_ARGUMENT; } else if (ret > 0) { diff --git a/apps/wolfsshd/test/test_configuration.c b/apps/wolfsshd/test/test_configuration.c index 8d35c20f..75708d53 100644 --- a/apps/wolfsshd/test/test_configuration.c +++ b/apps/wolfsshd/test/test_configuration.c @@ -301,6 +301,10 @@ static int test_ParseConfigLine(void) {"Invalid login grace time", "LoginGraceTime wolfsshd", 1}, {"Bare multiplier m (no digit)", "LoginGraceTime m", 1}, {"Bare multiplier h (no digit)", "LoginGraceTime h", 1}, + {"Valid login grace time zero", "LoginGraceTime 0", 0}, + {"Valid login grace time zero minutes", "LoginGraceTime 0m", 0}, + {"Valid login grace time zero hours", "LoginGraceTime 0h", 0}, + {"Invalid zero padded login grace time", "LoginGraceTime 00", 1}, /* Permit empty password tests. */ {"Permit empty password no", "PermitEmptyPasswords no", 0},