diff options
author | Koen Vandeputte <koen.vandeputte@ncentric.com> | 2016-12-22 17:17:04 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-12-26 11:17:33 +0100 |
commit | 2912f9f2a2e5997df069d38e20d85ff4cc51acef (patch) | |
tree | 783e8cd472936ac1ca9378f16fb3189a486e7a48 /toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch | |
parent | b97c933ffb5aae338351a1db12a3f7cf5234f5c7 (diff) | |
download | mtk-20170518-2912f9f2a2e5997df069d38e20d85ff4cc51acef.zip mtk-20170518-2912f9f2a2e5997df069d38e20d85ff4cc51acef.tar.gz mtk-20170518-2912f9f2a2e5997df069d38e20d85ff4cc51acef.tar.bz2 |
musl: backport various post-1.1.15 fixes
Backport most important fixes up to latest HEAD
- Taken post-commit reverts/fixes into account
Compile tested
Run-tested on cns3xxx & imx6 targets
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Diffstat (limited to 'toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch')
-rw-r--r-- | toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch b/toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch new file mode 100644 index 0000000..6db6fd8 --- /dev/null +++ b/toolchain/musl/patches/065-fix-integer-overflow-of-tm_year-in-__secs_to_tm.patch @@ -0,0 +1,39 @@ +From bc1e7731cee963e422575f81048792f4d5db9641 Mon Sep 17 00:00:00 2001 +From: Daniel Sabogal <dsabogal@ufl.edu> +Date: Wed, 2 Nov 2016 22:29:36 -0400 +Subject: fix integer overflow of tm_year in __secs_to_tm + +the overflow check for years+100 did not account for the extra +year computed from the remaining months. instead, perform this +check after obtaining the final number of years. +--- + src/time/__secs_to_tm.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/time/__secs_to_tm.c b/src/time/__secs_to_tm.c +index 3a3123a..093d902 100644 +--- a/src/time/__secs_to_tm.c ++++ b/src/time/__secs_to_tm.c +@@ -60,15 +60,16 @@ int __secs_to_tm(long long t, struct tm *tm) + for (months=0; days_in_month[months] <= remdays; months++) + remdays -= days_in_month[months]; + ++ if (months >= 10) { ++ months -= 12; ++ years++; ++ } ++ + if (years+100 > INT_MAX || years+100 < INT_MIN) + return -1; + + tm->tm_year = years + 100; + tm->tm_mon = months + 2; +- if (tm->tm_mon >= 12) { +- tm->tm_mon -=12; +- tm->tm_year++; +- } + tm->tm_mday = remdays + 1; + tm->tm_wday = wday; + tm->tm_yday = yday; +-- +cgit v0.11.2 |