Mercurial > ecos-v3_0-branch
changeset 2547:3cff44606584
Use signed ints for loops - prevents infinite loops on bad data
| author | gthomas |
|---|---|
| date | Tue, 09 Sep 2008 11:34:09 +0000 |
| parents | 28ecf71a7103 |
| children | 571e0ca40e73 |
| files | packages/io/wallclock/current/ChangeLog packages/io/wallclock/current/include/wallclock/wallclock.inl |
| diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/io/wallclock/current/ChangeLog +++ b/packages/io/wallclock/current/ChangeLog @@ -1,3 +1,9 @@ +2008-09-09 Gary Thomas <gary@mlbassoc.com> + + * include/wallclock/wallclock.inl (_simple_mktime): Use signed + integers for loops (more correct if input data is invalid and + asserts aren't on) + 2007-01-14 Gary Thomas <gary@mlbassoc.com> * src/wallclock.cxx: Use a mutex for exclusion during get/set
--- a/packages/io/wallclock/current/include/wallclock/wallclock.inl +++ b/packages/io/wallclock/current/include/wallclock/wallclock.inl @@ -76,7 +76,7 @@ static time_t cyg_uint32 min, cyg_uint32 sec) { time_t secs; - cyg_uint32 y, m, days; + cyg_int32 y, m, days; CYG_ASSERT(year <= 3124, "Year is unreasonably large"); CYG_ASSERT(mon <= 12, "Month is invalid"); @@ -87,11 +87,11 @@ static time_t // Number of days due to years days = 0; - for (y = 1970; y < year; y++) + for (y = 1970; y < (cyg_int32)year; y++) days += year_days(y); // Due to months - for (m = 0; m < mon-1; m++) + for (m = 0; m < (cyg_int32)mon-1; m++) days += days_per_month[is_leap(year)][m]; // Add days days += day - 1;
