mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
gsocket: Fix potential multiplication overflow calculating timeout
socket->priv->timeout is only a guint, and the multiplication is performed before it’s widened to gint64 to be stored in start_time (thanks, C). This means any timeout of 50 days or more would overflow. Fixing this bug makes me feel a real sense of self-worth. Coverity ID: 1159478 Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
0e0b5dff7c
commit
1f396fd7d6
@ -3857,7 +3857,7 @@ g_socket_condition_timed_wait (GSocket *socket,
|
|||||||
|
|
||||||
if (socket->priv->timeout &&
|
if (socket->priv->timeout &&
|
||||||
(timeout < 0 || socket->priv->timeout < timeout / G_USEC_PER_SEC))
|
(timeout < 0 || socket->priv->timeout < timeout / G_USEC_PER_SEC))
|
||||||
timeout = socket->priv->timeout * 1000;
|
timeout = (gint64) socket->priv->timeout * 1000;
|
||||||
else if (timeout != -1)
|
else if (timeout != -1)
|
||||||
timeout = timeout / 1000;
|
timeout = timeout / 1000;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user