]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/passwd.c: Add overflow check
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 20 Dec 2023 19:48:54 +0000 (20:48 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 5 Jan 2024 21:41:12 +0000 (15:41 -0600)
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>
src/passwd.c

index a24e62dfd020b794de0bec9fa7203c75890ae513..f494a9257ee7266c2d1eca40ba51e8dc1d7d71dd 100644 (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) {