From nobody Tue Jul 04 03:08:22 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qw75y5rhPz4lRmK; Tue, 4 Jul 2023 03:08:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qw75y53hPz3xRj; Tue, 4 Jul 2023 03:08:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688440102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eek7WVvx4wI3fx+k/B8Ob0olqFHRdAhYSPf54SaTR+w=; b=WX2t2gE6XJIH9o6C7uPS53eEmA386RlBpKitixpftYq3sPwHWAaLtYVd5G6jDdsxf+fFWt 0cKVBtKjnZjprqyAImjXzVnJaMG6cJKv/XZLZJBnricEocFoffT3ZFTL1A8E96Jc85c13A lB8BCxLq3Tav+GAZOK2VkvaOO7dRKlNCvMQazOJa1S+c28Mu4ZA8ufN8wFqyKxwPrCSQY1 BdkCP3L7qHF2oqrtkv0DHVVXb1WbgwjTTwfLgnJPG8zi9RuoEhNpNtDbT+VyS3jxbE8HqN G5mzQGsQDY6evHnR+kqwlKq060W1eOGiXtEMkL196MAhFLIgstDwJmn8NjducQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688440102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eek7WVvx4wI3fx+k/B8Ob0olqFHRdAhYSPf54SaTR+w=; b=U96uFkfEDeLbqZ6Fhqz4Ccv8bAVDO2JHHEGLldEiEz8N93aEbcgGeNQS4VPt3fy/aNAEzH Diy9gjiS2qbpVGQXkf9JK6azF5fPFPDQj3IJIPfLKZA86FPAn065cpqCT1x90PLHg9lDyi Ts6MD7Ss9ZzD3YQunv6qdB2l5rbk7o1c2bwpzjVoOiELp1qHc8KXAgDr8M+pBWjgggyN0/ QDz50YYbgRkLCWrntO7mfofaJcgxlaqeU9QotDCciJwBbn4dAENAnCrP6NrAsIK4lFCrkV 3tv/CgXEP3GFgoJcTgh4H2A0BRysqvCWEYD4oU+wGZPWQsk23N3dAC0q43Jg1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688440102; a=rsa-sha256; cv=none; b=qOlcor9/IXwc0/xeAWzm02ud6m57Iny3kA3+R3FaOLetvENcGZMRCv/s6yTADEBlQn44WE Y3lMVakJHhkA6l9LpR9wRvoVIbtjBNP2HpZJleQleTTeiJ+Fl9JzA0+HOZBSGdXHFMs34L Ehea2iu6Gx7yoyKJIuWzdvKeNQhpksfbc1QpLhF5sUCz5tVWu5pskff8ICNp/rrXPlBQ/g SWDKHtY/JQEeGHshXFRs330oK06V+sU0mp627jlJXXn1xOiH+SdsRDce+lA3C2UHfIBtl1 VtR72/DyB/CqBqXvPbyO9jUGt44cMWzok8+v9PE1bmCWxE/v1BUSAlXTAvQsaA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qw75y3ZrQzGTm; Tue, 4 Jul 2023 03:08:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36438MAR093772; Tue, 4 Jul 2023 03:08:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36438MTA093771; Tue, 4 Jul 2023 03:08:22 GMT (envelope-from git) Date: Tue, 4 Jul 2023 03:08:22 GMT Message-Id: <202307040308.36438MTA093771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Pedro F. Giffuni" Subject: git: 4456846a1a0d - main - bin/date: Upgrade calculations List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pfg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf commit 4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf Author: Pedro F. Giffuni AuthorDate: 2023-07-03 02:32:10 +0000 Commit: Pedro F. Giffuni CommitDate: 2023-07-04 03:08:01 +0000 bin/date: Upgrade calculations Use long instead of int for numerous calculations, fixing a number of date calculation overflow issues. Obtained from: DragonflyBSD Git log: 4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only partial) --- bin/date/vary.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/date/vary.c b/bin/date/vary.c index 5f0123110ee3..6f3c59950ecf 100644 --- a/bin/date/vary.c +++ b/bin/date/vary.c @@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$"); #include "vary.h" struct trans { - int val; + long val; const char *str; }; @@ -52,7 +52,7 @@ static struct trans trans_wday[] = { }; static char digits[] = "0123456789"; -static int adjhour(struct tm *, char, int, int); +static int adjhour(struct tm *, char, long, int); static int domktime(struct tm *t, char type) @@ -125,7 +125,7 @@ daysinmonth(const struct tm *t) static int -adjyear(struct tm *t, char type, int val, int mk) +adjyear(struct tm *t, char type, long val, int mk) { switch (type) { case '+': @@ -146,7 +146,7 @@ adjyear(struct tm *t, char type, int val, int mk) } static int -adjmon(struct tm *t, char type, int val, int istext, int mk) +adjmon(struct tm *t, char type, long val, int istext, int mk) { int lmdays; @@ -206,7 +206,7 @@ adjmon(struct tm *t, char type, int val, int istext, int mk) } static int -adjday(struct tm *t, char type, int val, int mk) +adjday(struct tm *t, char type, long val, int mk) { int lmdays; @@ -250,7 +250,7 @@ adjday(struct tm *t, char type, int val, int mk) } static int -adjwday(struct tm *t, char type, int val, int istext, int mk) +adjwday(struct tm *t, char type, long val, int istext, int mk) { if (val < 0) return 0; @@ -286,7 +286,7 @@ adjwday(struct tm *t, char type, int val, int istext, int mk) } static int -adjhour(struct tm *t, char type, int val, int mk) +adjhour(struct tm *t, char type, long val, int mk) { if (val < 0) return 0; @@ -331,7 +331,7 @@ adjhour(struct tm *t, char type, int val, int mk) } static int -adjmin(struct tm *t, char type, int val, int mk) +adjmin(struct tm *t, char type, long val, int mk) { if (val < 0) return 0; @@ -372,7 +372,7 @@ adjmin(struct tm *t, char type, int val, int mk) } static int -adjsec(struct tm *t, char type, int val, int mk) +adjsec(struct tm *t, char type, long val, int mk) { if (val < 0) return 0; @@ -419,7 +419,7 @@ vary_apply(const struct vary *v, struct tm *t) char which; char *arg; size_t len; - int val; + long val; for (; v; v = v->next) { type = *v->arg;