Skip to content

Refactor timespec to microsecond conversion

Ossama Othman ell 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4time: Add timespec to microseconds converterell/ell.sym ell/time.c ell/time.h+28 -01 reply
2/4unit: Add l_timespec_to_usecs() unit test.unit/test-time.c+34 -01 reply
3/4time: Use l_timespec_to_usecs() to avoid overflow.ell/time.c+1 -11 reply
4/4path: Use l_timespec_to_usecs() to avoid overflow.ell/path.c+1 -22 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] Refactor timespec to microsecond conversion

An integer overflow fix for a timespec to microsecond conversion in l_path_get_mtime() was previously committed but two overflows could still occur: (1) the multiplication in the seconds (tv_sec) to microsecond conversion could still exceed UINT64_MAX, and (2) addition of the microseconds obtained from the nanoseconds (tv_nsec) member could also result in a sum that exceeds UINT64_MAX.

This set of patches refactors the timespec to microsecond to a new l_timespec_to_usecs() function that checks for overflow in both of the cases mentioned above. The l_path_get_mtime() function now uses l_timespec_to_usecs() to address the remaining potential integer overflows. A potential integer overflow in the l_time_now() function was corrected in a similar manner.

Ossama Othman (4):
time: Add timespec to microseconds converter
unit: Add l_timespec_to_usecs() unit test.
time: Use l_timespec_to_usecs() to avoid overflow.
path: Use l_timespec_to_usecs() to avoid overflow.

 ell/ell.sym      |  1 +
 ell/path.c       |  3 +--
 ell/time.c       | 26 +++++++++++++++++++++++++-
 ell/time.h       |  3 +++
 unit/test-time.c | 34 ++++++++++++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1