summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/replace/timegm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source4/lib/replace/timegm.c b/source4/lib/replace/timegm.c
index ff90626d44..608882d0ce 100644
--- a/source4/lib/replace/timegm.c
+++ b/source4/lib/replace/timegm.c
@@ -44,13 +44,22 @@ static int is_leap(unsigned y)
return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
}
-time_t timegm(struct tm *tm)
+time_t rep_timegm(struct tm *tm)
{
static const unsigned ndays[2][12] ={
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
time_t res = 0;
unsigned i;
+
+ if (tm->tm_mon > 12 ||
+ tm->tm_mday > 31 ||
+ tm->tm_min > 60 ||
+ tm->tm_sec > 60 ||
+ tm->tm_hour > 24) {
+ /* invalid tm structure */
+ return 0;
+ }
for (i = 70; i < tm->tm_year; ++i)
res += is_leap(i) ? 366 : 365;