mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
keepalive: Guard against integer overflow
Don't allow interval to be > MAX_INT/1000 in virKeepAliveStart() Guard against possible overflow in virKeepAliveTimeout() by setting the timeout to be MAX_INT/1000 since the math following will multiply it by 1000.
This commit is contained in:
parent
567779e51a
commit
903f43ce6d
@ -252,6 +252,12 @@ virKeepAliveStart(virKeepAlivePtr ka,
|
|||||||
_("keepalive interval already set"));
|
_("keepalive interval already set"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
/* Guard against overflow */
|
||||||
|
if (interval > INT_MAX / 1000) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("keepalive interval %d too large"), interval);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
ka->interval = interval;
|
ka->interval = interval;
|
||||||
ka->count = count;
|
ka->count = count;
|
||||||
ka->countToDeath = count;
|
ka->countToDeath = count;
|
||||||
@ -323,6 +329,9 @@ virKeepAliveTimeout(virKeepAlivePtr ka)
|
|||||||
timeout = ka->interval - (time(NULL) - ka->intervalStart);
|
timeout = ka->interval - (time(NULL) - ka->intervalStart);
|
||||||
if (timeout < 0)
|
if (timeout < 0)
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
/* Guard against overflow */
|
||||||
|
if (timeout > INT_MAX / 1000)
|
||||||
|
timeout = INT_MAX / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectUnlock(ka);
|
virObjectUnlock(ka);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user