Re: [PATCH 2/3] xen: Check return value of virStringReplace

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

 



On Tue, Feb 23, 2016 at 09:49:08AM +0100, Michal Privoznik wrote:
> After 6604a3dd9f8 in which new helper function has been
> introduced, the code calls virStringReplace and dereference the
> result immediately. The string function can, however, return NULL
> so this would SIGSEGV right away. Check for the return value of
> the string function.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/xenconfig/xen_xl.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 

ACK with the virReportError removed.

> diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
> index 585ef9b..e65f5c6 100644
> --- a/src/xenconfig/xen_xl.c
> +++ b/src/xenconfig/xen_xl.c
> @@ -254,7 +254,12 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
>      int ret = -1;
>  
>      if (STRPREFIX(srcstr, "rbd:")) {
> -        tmpstr = virStringReplace(srcstr, "\\\\", "\\");
> +        if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\"))) {

virStringReplace reports an error on OOM.

> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("Unable to parse disk source string: %s"),
> +                           srcstr);

This error is wrong and would overwrite the OOM error (or wouldn't,
since there's no memory for it).

Jan

> +            goto cleanup;
> +        }
>  

--
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]