Re: [PATCH 14/18] conf: use disk source accessors in vmware/

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

 



On 03/19/2014 11:20 AM, Eric Blake wrote:
> Part of a series of cleanups to use new accessor methods.
>
> While writing this, I also discovered that conversion from XML
> to vmware modified the disk source in place; if the same code
> is reached twice, the second call behaves differently because
> the first call didn't clean up its mess.
>
> * src/vmware/vmware_conf.c (vmwareVmxPath): Use accessors.
> (vmwareParsePath): Avoid munging input string.
> * src/vmware/vmware_conf.h (vmwareParsePath): Make static.
>
> Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
> ---
>  src/vmware/vmware_conf.c | 18 ++++++++++--------
>  src/vmware/vmware_conf.h |  6 +++---
>  2 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
> index c96bd62..2de24a7 100644
> --- a/src/vmware/vmware_conf.c
> +++ b/src/vmware/vmware_conf.c
> @@ -331,15 +331,15 @@ vmwareDomainConfigDisplay(vmwareDomainPtr pDomain, virDomainDefPtr def)
>      }
>  }
>
> -int
> -vmwareParsePath(char *path, char **directory, char **filename)
> +static int
> +vmwareParsePath(const char *path, char **directory, char **filename)
>  {
>      char *separator;
>
>      separator = strrchr(path, '/');
>
>      if (separator != NULL) {
> -        *separator++ = '\0';
> +        separator++;
>
>          if (*separator == '\0') {
>              virReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -347,7 +347,7 @@ vmwareParsePath(char *path, char **directory, char **filename)
>              return -1;
>          }
>
> -        if (VIR_STRDUP(*directory, path) < 0)
> +        if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0)

So this fixes the bug you mentioned in the log message. Might be better
if it was a different patch. (No need to resend though) (BTW, you
haven't seen any ACKs yet because I'm going to give one for the whole
series to reduce clutter :-)

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