Skip to content

Commit b1ceb30

Browse files
committed
mapi_lib: reorder time checks in props_to_defer_interval
``if (*send_time < submit_time)`` logically implies ``if (nttime_to_unix(*send_time) < nttime_to_unix(submit_time))``, i.e. ``if (nttime_to_unix(*send_time) < nttime_to_unix(unix_to_nttime(cur_time))``, i.e. ``if (nttime_to_unix(*send_time) < cur_time``. But because the time conversion functions have recently gained clamping, these conditions no longer hold. Reorder the is-less-than test after time conversions to nudge cov-scan. CID 1596023: (#1 of 1): Overflowed return value (INTEGER_OVERFLOW) 5. return_overflow: rop_util_nttime_to_unix(*send_time) - cur_time, which might have overflowed, is returned from the function. Fixes: gromox-2.44-52-g438424e5f
1 parent d57e772 commit b1ceb30

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/mapi/rop_util.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,18 @@ XID::XID(GUID g, eid_t change_num) : guid(g), size(22)
248248

249249
namespace gromox {
250250

251+
/**
252+
* Return number of seconds of how long to hold/defer a message.
253+
*/
251254
uint32_t props_to_defer_interval(const TPROPVAL_ARRAY &pv)
252255
{
253256
auto cur_time = time(nullptr);
254-
auto submit_time = rop_util_unix_to_nttime(cur_time);
255257
auto send_time = pv.get<const uint64_t>(PR_DEFERRED_SEND_TIME);
256258
if (send_time != nullptr) {
257-
if (*send_time < submit_time)
259+
auto ut_send_time = rop_util_nttime_to_unix(*send_time);
260+
if (ut_send_time < cur_time)
258261
return 0;
259-
return rop_util_nttime_to_unix(*send_time) - cur_time;
262+
return ut_send_time - cur_time;
260263
}
261264
auto num = pv.get<const uint32_t>(PR_DEFERRED_SEND_NUMBER);
262265
if (num == nullptr)

0 commit comments

Comments
 (0)