Skip to content

Commit 5fa7f44

Browse files
Sergey Komarovjengelh
authored andcommitted
nsp: check return value of mktime()
CID 1558654: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW) 2. known_value_assign: tmp_time = mktime(&tmp_tm), its value is now -1. 3. overflow_const: Expression (uint64_t)tmp_time + 11644473600ULL, where (uint64_t)tmp_time is known to be equal to -1, underflows the type of (uint64_t)tmp_time + 11644473600ULL, which is type unsigned long long. Fixes: gromox-0~666
1 parent 40c7ae0 commit 5fa7f44

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

exch/nsp/common_util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ void common_util_day_to_filetime(const char *day, FILETIME *pftime)
4141
memset(&tmp_tm, 0, sizeof(tmp_tm));
4242
strptime(day, "%Y-%m-%d", &tmp_tm);
4343
tmp_time = mktime(&tmp_tm);
44+
if (tmp_time == -1) {
45+
*pftime = {};
46+
return;
47+
}
4448
file_time = ((uint64_t)tmp_time + EPOCH_DIFF)*10000000;
4549
pftime->low_datetime = file_time & 0xFFFFFFFF;
4650
pftime->high_datetime = file_time >> 32;

0 commit comments

Comments
 (0)