shadow/backport-src-passwd-add-overflow-check.patch
z30023234 5d22cefb4a backport some patches
(cherry picked from commit 76c1b9426d399c8f9a97f46779db76f409c7fbcc)
2024-02-05 20:57:22 +08:00

33 lines
1.0 KiB
Diff

From 2d188a9987789f019dae2d46c50578a474ab2bdd Mon Sep 17 00:00:00 2001
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Wed, 20 Dec 2023 20:48:54 +0100
Subject: [PATCH] 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>
Reference: https://github.com/shadow-maint/shadow/commit/2d188a9987789f019dae2d46c50578a474ab2bdd
Conflict: NA
---
src/passwd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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) {