1 From bc1e7731cee963e422575f81048792f4d5db9641 Mon Sep 17 00:00:00 2001
2 From: Daniel Sabogal <dsabogal@ufl.edu>
3 Date: Wed, 2 Nov 2016 22:29:36 -0400
4 Subject: fix integer overflow of tm_year in __secs_to_tm
6 the overflow check for years+100 did not account for the extra
7 year computed from the remaining months. instead, perform this
8 check after obtaining the final number of years.
10 src/time/__secs_to_tm.c | 9 +++++----
11 1 file changed, 5 insertions(+), 4 deletions(-)
13 diff --git a/src/time/__secs_to_tm.c b/src/time/__secs_to_tm.c
14 index 3a3123a..093d902 100644
15 --- a/src/time/__secs_to_tm.c
16 +++ b/src/time/__secs_to_tm.c
17 @@ -60,15 +60,16 @@ int __secs_to_tm(long long t, struct tm *tm)
18 for (months=0; days_in_month[months] <= remdays; months++)
19 remdays -= days_in_month[months];
26 if (years+100 > INT_MAX || years+100 < INT_MIN)
29 tm->tm_year = years + 100;
30 tm->tm_mon = months + 2;
31 - if (tm->tm_mon >= 12) {
35 tm->tm_mday = remdays + 1;