From c2e6dfc3144a4d46068f2b7ced3664a082f8befb Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 3 Mar 2026 16:34:19 +0100 Subject: [PATCH] Reduce chance for overflow in ParseTime Without this patch, an input of 802M (months) could surprisingly produce a negative return value. Use `atoi` to match the type of the tmp variable. This patch was done while reviewing potential year-2038 issues in openSUSE. --- storage/interface.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/interface.c b/storage/interface.c index 19688bb6e..a5835c454 100644 --- a/storage/interface.c +++ b/storage/interface.c @@ -226,19 +226,19 @@ ParseTime(char *tmbuf) startnum = tmbuf; while (*tmbuf) { if (!isdigit((unsigned char) *tmbuf)) { - tmp = atol(startnum); + tmp = atoi(startnum); switch (*tmbuf) { case 'M': - ret += tmp * 60 * 60 * 24 * 31; + ret += tmp * 60LL * 60 * 24 * 31; break; case 'd': - ret += tmp * 60 * 60 * 24; + ret += tmp * 60LL * 60 * 24; break; case 'h': - ret += tmp * 60 * 60; + ret += tmp * 60LL * 60; break; case 'm': - ret += tmp * 60; + ret += tmp * 60LL; break; case 's': ret += tmp;