aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2023-07-03 02:32:10 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2023-07-04 03:08:01 +0000
commit4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf (patch)
tree51aa6c6a01cf1fe47515062cf80b330c23711861 /bin
parentee8b0c436d7221c25e8be3c3fe1f9da78b9d5b16 (diff)
downloadsrc-4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf.tar.gz
src-4456846a1a0d8cb6d0e6bae89f1134fa0a1af5cf.zip
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)
Diffstat (limited to 'bin')
-rw-r--r--bin/date/vary.c20
1 files 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;