src/passwd.c: Add overflow check

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: <https://github.com/shadow-maint/shadow/pull/876>
Co-developed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Tobias Stoeckmann
2023-12-20 20:48:54 +01:00
committed by Serge Hallyn
parent 3b5ba41d3e
commit 2d188a9987

View File

@@ -387,8 +387,9 @@ static void check_password (const struct passwd *pw, const struct spwd *sp)
long now, ok;
now = time(NULL) / DAY;
ok = sp->sp_lstchg;
if (sp->sp_min > 0) {
ok += sp->sp_min;
if ( (sp->sp_min > 0)
&& __builtin_add_overflow(ok, sp->sp_min, &ok)) {
ok = LONG_MAX;
}
if (now < ok) {