diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-01-28 19:06:53 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2019-01-31 17:40:24 +0100 |
commit | 89991fdb7c01fa42e323577b4026985e580763cf (patch) | |
tree | b91957962a41177a61365a1719a6eddcd0b5593b /src/sim/sim_int.h | |
parent | bd5a1dc84f0124d99a89ac187f15c7d34beea210 (diff) |
osmo_fsm_inst_state_chg(): clamp timeout_secs to <= ~68 years
During testing of the upcoming tdef API, it became apparent that passing very
large timeout values to osmo_fsm_inst_state_chg() wraps back in the number
range, and might actually result in effectively very short timeouts instead.
Since time_t's range is not well defined across platforms, use a reasonable
maximum value of signed 32 bit integer. Hence this will be safe at least on
systems with an int32_t for struct timeval.tv_sec and larger.
Clamp the osmo_fsm_inst_state_chg() timeout_secs argument to a maximum of
0x7fffffff, which amounts to just above 68 years:
float(0x7fffffff) / (60. * 60 * 24 * 365.25) = 68.04965038532715
(In upcoming patch Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5, this can be
verified to work by invoking tdef_test manually with a cmdline argument passed
to enable the range check.)
Change-Id: I35ec4654467b1d6040c8aa215049766089e5e64a
Diffstat (limited to 'src/sim/sim_int.h')
0 files changed, 0 insertions, 0 deletions