[libvirt] [PATCH] daemon: Error and exit if specified value for timeout is not valid

Osier Yang jyang at redhat.com
Tue Sep 20 03:20:15 UTC 2011


于 2011年09月20日 08:16, Eric Blake 写道:
> On 09/19/2011 08:28 AM, Osier Yang wrote:
>> Silently setting "timeout" as -1 if the specified value is invalid
>> is a bit confused.
>> ---
>> daemon/libvirtd.c | 6 ++++--
>> 1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
>> index c708ff7..4dd68d5 100644
>> --- a/daemon/libvirtd.c
>> +++ b/daemon/libvirtd.c
>> @@ -1311,8 +1311,10 @@ int main(int argc, char **argv) {
>> if (virStrToLong_i(optarg,&tmp, 10,&timeout) != 0
>> || timeout<= 0
>> /* Ensure that we can multiply by 1000 without overflowing. */
>> - || timeout> INT_MAX / 1000)
>> - timeout = -1;
>> + || timeout> INT_MAX / 1000) {
>> + VIR_ERROR(_("Invalid value for timeout"));
>> + exit(EXIT_FAILURE);
>> + }
>
> ACK. Minimal impact (only those doing odd command lines in the first 
> place), and if someone was really relying on '-t -1' as a way to get 
> (effectively) infinite timeouts, they can still get fake it with '-t 
> $((1<<32 / 1000))'. Okay for 0.9.5.
>

Pushed. Thanks

Osier




More information about the libvir-list mailing list