From: Tobias Stoeckmann Date: Wed, 20 Dec 2023 19:48:54 +0000 (+0100) Subject: src/passwd.c: Add overflow check X-Git-Tag: 4.15.0-rc1~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d188a9987789f019dae2d46c50578a474ab2bdd;p=thirdparty%2Fshadow.git src/passwd.c: Add overflow check Signed-off-by: Tobias Stoeckmann Link: Co-developed-by: Alejandro Colomar Signed-off-by: Alejandro Colomar --- diff --git a/src/passwd.c b/src/passwd.c index a24e62dfd..f494a9257 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -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) {