mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2025-11-21 00:52:56 +00:00
Avoid integer overflow in mktime
* localtime.c (time2sub), NEWS: Avoid signed arithmetic overflow. (Problem reported by Jörg Richter.)
This commit is contained in:
5
NEWS
5
NEWS
@ -29,6 +29,11 @@ Unreleased, experimental changes
|
||||
Correct the 1992-2010 DST abbreviation in Volgograd from "MSK" to "MSD".
|
||||
(Thanks to Hank W.)
|
||||
|
||||
Changes affecting code
|
||||
|
||||
Fix integer overflow bug in reference 'mktime' implementation.
|
||||
(Problem reported by Jörg Richter.)
|
||||
|
||||
Changes affecting commentary
|
||||
|
||||
Cite the recent Mexican decree changing Quintana Roo's time zone.
|
||||
|
||||
15
localtime.c
15
localtime.c
@ -1783,10 +1783,10 @@ time2sub(struct tm *const tmp,
|
||||
register int dir;
|
||||
register int i, j;
|
||||
register int saved_seconds;
|
||||
register int_fast32_t li;
|
||||
register int_fast32_t li;
|
||||
register time_t lo;
|
||||
register time_t hi;
|
||||
int_fast32_t y;
|
||||
int_fast32_t y;
|
||||
time_t newt;
|
||||
time_t t;
|
||||
struct tm yourtm, mytm;
|
||||
@ -1861,15 +1861,8 @@ time2sub(struct tm *const tmp,
|
||||
/*
|
||||
** Do a binary search (this works whatever time_t's type is).
|
||||
*/
|
||||
if (!TYPE_SIGNED(time_t)) {
|
||||
lo = 0;
|
||||
hi = lo - 1;
|
||||
} else {
|
||||
lo = 1;
|
||||
for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i)
|
||||
lo *= 2;
|
||||
hi = -(lo + 1);
|
||||
}
|
||||
lo = time_t_min;
|
||||
hi = time_t_max;
|
||||
for ( ; ; ) {
|
||||
t = lo / 2 + hi / 2;
|
||||
if (t < lo)
|
||||
|
||||
Reference in New Issue
Block a user