[libvirt] [PATCH] keepalive: Guard against integer overflow
Eric Blake
eblake at redhat.com
Wed Feb 20 21:04:22 UTC 2013
On 02/20/2013 02:02 PM, Eric Blake wrote:
> On 02/20/2013 01:51 PM, John Ferlan wrote:
>> 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 is a follow-up of sorts from a Coverity change made last month:
>>
>> https://www.redhat.com/archives/libvir-list/2013-January/msg02267.html
>>
>> where it was noted that the timeout value math needed overflow protection.
>>
>> ---
>> src/rpc/virkeepalive.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>
> ACK.
I hit send prematurely. What you have is fine, but it could be improved
slightly:
>> + /* Guard against overflow */
>> + if (interval > INT_MAX / 1000) {
>> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>> + _("keepalive interval too large"));
>> + goto cleanup;
Instead of "%s", _("too large"), it would be better to have _("keepalive
interval %d too large), interval
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130220/4715e1b1/attachment-0001.sig>
More information about the libvir-list
mailing list