----- On Nov 9, 2018, at 6:43 PM, Jonathan Rajotte jonathan.rajotte-jul...@efficios.com wrote:
>> diff --git a/src/common/utils.c b/src/common/utils.c >> index 3442bef8..5b4e1d3c 100644 >> --- a/src/common/utils.c >> +++ b/src/common/utils.c [...] >> +LTTNG_HIDDEN >> +int timespec_to_ms(struct timespec ts, unsigned long *ms) >> +{ >> + unsigned long res; >> + >> + if (ts.tv_sec + 1 > ULONG_MAX / MSEC_PER_SEC) { >> + return -1; >> + } > > This is not accurate. It return -1 for the all the following valid timespec: > > tv_sec = 4294967 > 0 < tv_nsec < 295000000 > > You will need to check multiplication and addition separately. Good point! Changing the check for: if (ts.tv_sec + ts.tv_nsec / NSEC_PER_SEC > ULONG_MAX / MSEC_PER_SEC) { return -1; } Indeed it appears to be valid to have tv_nsec greater than (1000000000-1) Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list lttng-dev@lists.lttng.org https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev