* [rtc-linux] [PATCH v2] rtc: fix overflow and incorrect calculation in rtc_time64_to_tm
@ 2015-12-04 4:01 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2015-12-04 4:01 UTC (permalink / raw)
To: a.zummo, alexandre.belloni; +Cc: rtc-linux, linux-kernel, Sasha Levin
At some point after humans go extinct and robots cotrol the world, dividing
he time64_t by 86400 to extract the days will overflow a 32bit integer,
leading to incorrect conversion into rtc_time in rtc_time64_to_tm().
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
drivers/rtc/rtc-lib.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index e6bfb9c..cafae93 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -53,12 +53,11 @@ EXPORT_SYMBOL(rtc_year_days);
void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
{
unsigned int month, year;
- unsigned long secs;
- int days;
+ int secs;
+ time64_t days;
/* time must be positive */
- days = div_s64(time, 86400);
- secs = time - (unsigned int) days * 86400;
+ days = div_s64_rem(time, 86400, &secs);
/* day of the week, 1970-01-01 was a Thursday */
tm->tm_wday = (days + 4) % 7;
--
1.7.10.4
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] rtc: fix overflow and incorrect calculation in rtc_time64_to_tm
@ 2015-12-04 4:01 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2015-12-04 4:01 UTC (permalink / raw)
To: a.zummo, alexandre.belloni; +Cc: rtc-linux, linux-kernel, Sasha Levin
At some point after humans go extinct and robots cotrol the world, dividing
he time64_t by 86400 to extract the days will overflow a 32bit integer,
leading to incorrect conversion into rtc_time in rtc_time64_to_tm().
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
drivers/rtc/rtc-lib.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index e6bfb9c..cafae93 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -53,12 +53,11 @@ EXPORT_SYMBOL(rtc_year_days);
void rtc_time64_to_tm(time64_t time, struct rtc_time *tm)
{
unsigned int month, year;
- unsigned long secs;
- int days;
+ int secs;
+ time64_t days;
/* time must be positive */
- days = div_s64(time, 86400);
- secs = time - (unsigned int) days * 86400;
+ days = div_s64_rem(time, 86400, &secs);
/* day of the week, 1970-01-01 was a Thursday */
tm->tm_wday = (days + 4) % 7;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [rtc-linux] Re: [PATCH v2] rtc: fix overflow and incorrect calculation in rtc_time64_to_tm
2015-12-04 4:01 ` Sasha Levin
@ 2015-12-13 13:51 ` Alexandre Belloni
-1 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-12-13 13:51 UTC (permalink / raw)
To: Sasha Levin; +Cc: a.zummo, rtc-linux, linux-kernel
On 03/12/2015 at 23:01:14 -0500, Sasha Levin wrote :
> At some point after humans go extinct and robots cotrol the world, dividing
> he time64_t by 86400 to extract the days will overflow a 32bit integer,
> leading to incorrect conversion into rtc_time in rtc_time64_to_tm().
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> drivers/rtc/rtc-lib.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] rtc: fix overflow and incorrect calculation in rtc_time64_to_tm
@ 2015-12-13 13:51 ` Alexandre Belloni
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-12-13 13:51 UTC (permalink / raw)
To: Sasha Levin; +Cc: a.zummo, rtc-linux, linux-kernel
On 03/12/2015 at 23:01:14 -0500, Sasha Levin wrote :
> At some point after humans go extinct and robots cotrol the world, dividing
> he time64_t by 86400 to extract the days will overflow a 32bit integer,
> leading to incorrect conversion into rtc_time in rtc_time64_to_tm().
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> drivers/rtc/rtc-lib.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
Applied, thanks.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-13 13:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 4:01 [rtc-linux] [PATCH v2] rtc: fix overflow and incorrect calculation in rtc_time64_to_tm Sasha Levin
2015-12-04 4:01 ` Sasha Levin
2015-12-13 13:51 ` [rtc-linux] " Alexandre Belloni
2015-12-13 13:51 ` Alexandre Belloni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.