Commit 1f396fd7 authored by Philip Withnall's avatar Philip Withnall

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's avatarPhilip Withnall <>
parent 0e0b5dff
......@@ -3857,7 +3857,7 @@ g_socket_condition_timed_wait (GSocket *socket,
if (socket->priv->timeout &&
(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)
timeout = timeout / 1000;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment