diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-09-26 12:54:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-09-26 12:54:38 +0200 |
commit | 4a92d3943554681ce35e8106ef4f889c7a3bfed3 (patch) | |
tree | 26c5cf5d54904db0d30a2257f976595e05d3b5f7 /src/util/network.c | |
parent | fce0277df0380f3758749c84222f0d76b612385b (diff) | |
download | gnunet-4a92d3943554681ce35e8106ef4f889c7a3bfed3.tar.gz gnunet-4a92d3943554681ce35e8106ef4f889c7a3bfed3.zip |
fix integer overflow in cast to long for very large timeouts on 32-bit platforms
Diffstat (limited to 'src/util/network.c')
-rw-r--r-- | src/util/network.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/util/network.c b/src/util/network.c index 66a468e45..942288613 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -1793,10 +1793,18 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, | |||
1793 | _("Fatal internal logic error, process hangs in `%s' (abort with CTRL-C)!\n"), | 1793 | _("Fatal internal logic error, process hangs in `%s' (abort with CTRL-C)!\n"), |
1794 | "select"); | 1794 | "select"); |
1795 | } | 1795 | } |
1796 | tv.tv_sec = timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us; | 1796 | if (timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us > (unsigned long long) LONG_MAX) |
1797 | tv.tv_usec = | 1797 | { |
1798 | (timeout.rel_value_us - | 1798 | tv.tv_sec = LONG_MAX; |
1799 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); | 1799 | tv.tv_usec = 999999L; |
1800 | } | ||
1801 | else | ||
1802 | { | ||
1803 | tv.tv_sec = (long) (timeout.rel_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us); | ||
1804 | tv.tv_usec = | ||
1805 | (timeout.rel_value_us - | ||
1806 | (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.rel_value_us)); | ||
1807 | } | ||
1800 | return select (nfds, | 1808 | return select (nfds, |
1801 | (NULL != rfds) ? &rfds->sds : NULL, | 1809 | (NULL != rfds) ? &rfds->sds : NULL, |
1802 | (NULL != wfds) ? &wfds->sds : NULL, | 1810 | (NULL != wfds) ? &wfds->sds : NULL, |