mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-10 05:03:06 +03:00
[BZ #471] Fix imported from gnulib.
* time/mktime.c (leapyear, ydms_tm_diff): Year is of type long int, not int, to avoid problems when tm_year == INT_MAX and tm_mon > 12. (__mktime_intenral): Compute year using long int arithmetic, not int arithmetic, to avoid problems on hosts where time_t and long are 64 bits but int is 32.
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
2004-10-22 Paul Eggert <eggert@cs.ucla.edu>
|
2004-10-22 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
[BZ #471] Fix imported from gnulib.
|
||||||
|
* time/mktime.c (leapyear, ydms_tm_diff): Year is of type
|
||||||
|
long int, not int, to avoid problems when tm_year == INT_MAX
|
||||||
|
and tm_mon > 12.
|
||||||
|
(__mktime_intenral): Compute year using long int arithmetic,
|
||||||
|
not int arithmetic, to avoid problems on hosts where time_t
|
||||||
|
and long are 64 bits but int is 32.
|
||||||
|
|
||||||
[BZ #468] Import a fix from gnulib.
|
[BZ #468] Import a fix from gnulib.
|
||||||
* time/mktime.c [! DEBUG]: Do not include <string.h>.
|
* time/mktime.c [! DEBUG]: Do not include <string.h>.
|
||||||
It's needed only if DEBUG is nonzero.
|
It's needed only if DEBUG is nonzero.
|
||||||
|
@@ -77,7 +77,7 @@ verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0);
|
|||||||
|
|
||||||
/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
|
/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
|
||||||
static inline int
|
static inline int
|
||||||
leapyear (int year)
|
leapyear (long int year)
|
||||||
{
|
{
|
||||||
/* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
|
/* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
|
||||||
Also, work even if YEAR is negative. */
|
Also, work even if YEAR is negative. */
|
||||||
@@ -119,7 +119,7 @@ const unsigned short int __mon_yday[2][13] =
|
|||||||
If TP is null, return a nonzero value.
|
If TP is null, return a nonzero value.
|
||||||
If overflow occurs, yield the low order bits of the correct answer. */
|
If overflow occurs, yield the low order bits of the correct answer. */
|
||||||
static time_t
|
static time_t
|
||||||
ydhms_tm_diff (int year, int yday, int hour, int min, int sec,
|
ydhms_tm_diff (long int year, int yday, int hour, int min, int sec,
|
||||||
const struct tm *tp)
|
const struct tm *tp)
|
||||||
{
|
{
|
||||||
if (!tp)
|
if (!tp)
|
||||||
@@ -231,7 +231,8 @@ __mktime_internal (struct tm *tp,
|
|||||||
int mon_remainder = mon % 12;
|
int mon_remainder = mon % 12;
|
||||||
int negative_mon_remainder = mon_remainder < 0;
|
int negative_mon_remainder = mon_remainder < 0;
|
||||||
int mon_years = mon / 12 - negative_mon_remainder;
|
int mon_years = mon / 12 - negative_mon_remainder;
|
||||||
int year = year_requested + mon_years;
|
long int lyear_requested = year_requested;
|
||||||
|
long int year = lyear_requested + mon_years;
|
||||||
|
|
||||||
/* The other values need not be in range:
|
/* The other values need not be in range:
|
||||||
the remaining code handles minor overflows correctly,
|
the remaining code handles minor overflows correctly,
|
||||||
|
Reference in New Issue
Block a user