mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-20 19:41:58 +00:00
add safety checks for month
This commit is contained in:
1 parent
8346a60971
commit
7fccc2b75f
2 files changed
+2
-2
No files matched your search
+1
-1
@@ -26163,7 +26163,7 @@ uint64_t mg_timegm(unsigned int year, unsigned int month, unsigned int day,
|
|||||||
const uint64_t day_secs = 86400;
|
const uint64_t day_secs = 86400;
|
||||||
const uint64_t year_secs = 31536000;
|
const uint64_t year_secs = 31536000;
|
||||||
unsigned int y, ly;
|
unsigned int y, ly;
|
||||||
if (year < 1970) return 0;
|
if (year < 1970 || month == 0 || month > 12) return 0;
|
||||||
y = year - 1900;
|
y = year - 1900;
|
||||||
ly = month > 2 ? y + 1 : y;
|
ly = month > 2 ? y + 1 : y;
|
||||||
return (uint64_t) sec + 60 * min + 3600 * hour +
|
return (uint64_t) sec + 60 * min + 3600 * hour +
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ uint64_t mg_timegm(unsigned int year, unsigned int month, unsigned int day,
|
|||||||
const uint64_t day_secs = 86400;
|
const uint64_t day_secs = 86400;
|
||||||
const uint64_t year_secs = 31536000;
|
const uint64_t year_secs = 31536000;
|
||||||
unsigned int y, ly;
|
unsigned int y, ly;
|
||||||
if (year < 1970) return 0;
|
if (year < 1970 || month == 0 || month > 12) return 0;
|
||||||
y = year - 1900;
|
y = year - 1900;
|
||||||
ly = month > 2 ? y + 1 : y;
|
ly = month > 2 ? y + 1 : y;
|
||||||
return (uint64_t) sec + 60 * min + 3600 * hour +
|
return (uint64_t) sec + 60 * min + 3600 * hour +
|
||||||
|
|||||||
Reference in new issue
Block a user