WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 06 of 10] xl: Allocate memory for libxl_device_ni

To: Marek Marczykowski <marmarek@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 06 of 10] xl: Allocate memory for libxl_device_nic string members
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 3 Jun 2011 09:13:21 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 03 Jun 2011 01:14:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <eb7216a75b7d7a5de93c.1307054136@devel14>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <patchbomb.1307054130@devel14> <eb7216a75b7d7a5de93c.1307054136@devel14>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-06-02 at 23:35 +0100, Marek Marczykowski wrote:
> # HG changeset patch
> # User Marek Marczykowski <marmarek@xxxxxxxxxxxx>
> # Date 1306963069 -7200
> # Node ID eb7216a75b7d7a5de93c717401b447545022b582
> # Parent  3e5e8eaf2fe8352e584e7498fde21d6e76c3475b
> xl: Allocate memory for libxl_device_nic string members
> 
> Do not use argv directly - libxl_device_nic_destroy will try to free() it.
> 
> Signed-off-by: Marek Marczykowski <marmarek@xxxxxxxxxxxx>
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -4280,12 +4280,14 @@
>                  nic.mac[i] = val;
>              }
>          } else if (!strncmp("bridge=", *argv, 7)) {
> -            nic.bridge = (*argv) + 7;
> +            free(nic.bridge);
> +            nic.bridge = strdup((*argv) + 7);

For parsing the cfg files (which has a similar pattern) we defined a
helper, xlu_cfg_replace_string. I think a similar helper for the non
xlu_cfg case (e.g. replace_string) would be good here too.

Ian.


>          } else if (!strncmp("ip=", *argv, 3)) {
>              free(nic.ip);
>              nic.ip = strdup((*argv) + 3);
>          } else if (!strncmp("script=", *argv, 6)) {
> -            nic.script = (*argv) + 6;
> +            free(nic.script);
> +            nic.script = strdup((*argv) + 6);
>          } else if (!strncmp("backend=", *argv, 8)) {
>              if(libxl_name_to_domid(&ctx, ((*argv) + 8), &val)) {
>                  fprintf(stderr, "Specified backend domain does not exist, 
> defaulting to Dom0\n");
> @@ -4293,9 +4295,11 @@
>              }
>              nic.backend_domid = val;
>          } else if (!strncmp("vifname=", *argv, 8)) {
> -            nic.ifname = (*argv) + 8;
> +                     free(nic.ifname);
> +            nic.ifname = strdup((*argv) + 8);
>          } else if (!strncmp("model=", *argv, 6)) {
> -            nic.model = (*argv) + 6;
> +            free(nic.model);
> +            nic.model = strdup((*argv) + 6);
>          } else if (!strncmp("rate=", *argv, 5)) {
>          } else if (!strncmp("accel=", *argv, 6)) {
>          } else {
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>