Re: [PATCH 08/10] virt-login-shell: use single instead of double fork

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 03/05/2014 01:55 PM, Eric Blake wrote:
> On 03/05/2014 06:57 AM, John Ferlan wrote:
>> Coverity has found an issue (NEGATIVE_RETURNS)
>>
>> The 'nfdlist' is the culprit.
>>
> 
>>>  cleanup:
>>> +    for (i = 0; i < nfdlist; i++)
>>> +        VIR_FORCE_CLOSE(fdlist[i]);
>>
>> (41) Event negative_returns: 	Using unsigned variable "nfdlist" in a
>> loop exit condition.
>> Also see events: 	[negative_return_fn][var_assign]
> 
> Yep.  Fixing with this, as the obvious followup:
> 
> diff --git i/tools/virt-login-shell.c w/tools/virt-login-shell.c
> index 3ea7ade..abe7eeb 100644
> --- i/tools/virt-login-shell.c
> +++ w/tools/virt-login-shell.c
> @@ -339,8 +339,9 @@ main(int argc, char **argv)
>      /* At this point, the parent is now waiting for the child to exit,
>       * but as that may take a long time, we release resources now.  */
>  cleanup:
> -    for (i = 0; i < nfdlist; i++)
> -        VIR_FORCE_CLOSE(fdlist[i]);
> +    if (nfdlist > 0)
> +        for (i = 0; i < nfdlist; i++)
> +            VIR_FORCE_CLOSE(fdlist[i]);
>      VIR_FREE(fdlist);
>      virConfFree(conf);
>      if (dom)
> 
> 


ACK,

checked with my Coverity build too.

John

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]