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

Re: [libvirt] [PATCH 3/9] phyp: Break potential infinite loops



On Fri, Nov 06, 2009 at 04:28:01AM +0100, Matthias Bolte wrote:
> ---
>  src/phyp/phyp_driver.c |   13 +++++++++----
>  1 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> index 5379cd3..b94d0fa 100644
> --- a/src/phyp/phyp_driver.c
> +++ b/src/phyp/phyp_driver.c
> @@ -1040,9 +1040,13 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
>          goto err;
>      else {
>          while (got < nids) {
> -            if (ret[i] == '\n') {
> -                if (virStrToLong_i(id_c, &char_ptr, 10, &ids[got]) == -1)
> -                    return 0;
> +            if (ret[i] == '\0')
> +                break;
> +            else if (ret[i] == '\n') {
> +                if (virStrToLong_i(id_c, &char_ptr, 10, &ids[got]) == -1) {
> +                    VIR_ERROR("Cannot parse number from '%s'", id_c);
> +                    goto err;
> +                }
>                  memset(id_c, 0, 10);
>                  j = 0;
>                  got++;
> @@ -1112,7 +1116,8 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
>                  }
>                  char_ptr2++;
>                  domains = char_ptr2;
> -            }
> +            } else
> +                break;
>          }
>      }
>  

  Right, that looks way safer, thanks !

   ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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