Skip to content

Commit 73a3693

Browse files
committed
CDRIVER-752 int overflow in mongoc_cond_timedwait
On Solaris, at least, timeval.tv_sec is 32 bits. Cast to int64_t before multiplying by 1000 to avoid overflow when converting from seconds to ms.
1 parent 0728630 commit 73a3693

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mongoc/mongoc-thread-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mongoc_cond_timedwait (pthread_cond_t *cond,
4545

4646
bson_gettimeofday (&tv);
4747

48-
msec = (tv.tv_sec * 1000) + (tv.tv_usec / 1000) + timeout_msec;
48+
msec = ((int64_t)tv.tv_sec * 1000) + (tv.tv_usec / 1000) + timeout_msec;
4949

5050
to.tv_sec = msec / 1000;
5151
to.tv_nsec = (msec % 1000) * 1000 * 1000;

0 commit comments

Comments
 (0)