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

Re: [PATCH v2 2/4] tools: allow vchan XenStore paths more then 64 bytes long


  • To: <dmitry.semenets@xxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Tue, 27 Sep 2022 16:00:10 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Dmytro Semenets <dmytro_semenets@xxxxxxxx>
  • Delivery-date: Tue, 27 Sep 2022 15:00:34 +0000
  • Ironport-data: A9a23:kRSeSKAFbova8RVWkefolGt99h7EJp4KDTa0Yr1iHsdyfbJa/94HLcsJFMlSPqH4CM41jsrWWreElGSAQAlalYX0ke7CJO57bzywN8FA2AtTw1sb4YLeJSRDX7saEgeNzBnt1HGmb/DG3zdY8X4WChI6bh2BsrfnxZqLMTu1ac2+RelVyP7sPCNydYRXEN4btivSc2CQcnYqPfCgJN9mgeNrJnMI7+LAwfvdQxFsYKG8NwmId7Z9Gc/vy268T/OihKaNcDJRbVNs9eVFjTecwKIkdOCirsrZsHXhq/jLnAUMC2SK3PEN9M9gK4Swri2Cdk316eC8+8KsS+n4YDnzZOSD54yvk7LrDGHiuUF9TRaruT/OnrCDztRgSn8xYmiAmhAM8KTe+SAaQdr7lvADECAOvD8NycIaF2mSvhaHSPFj+wDUNv/YBSrlFfjMtBfXOXRehfl/0wPmM1s68ZzcXbRn+TbEbgUk4SGD2TQysr9yoZB4YJN2r0uvypx9pL6TXs1OPOF2rh/1/cDppsImEuPHehgaTvUdnkxDiJdZkI6S9emouLbAoRBJs7l9QJxZYrlZQXqZMOM/5KWZtVLN48z3MjIMGkIaXYeW6FGd5M1NVNF73W/jJdkXJW0c4DpJyMPW4NhiGmdLm7K5Zjkvv9ebJnE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ZnlB209NBFXPYz78poUKZ3EfDlLgz9Xmg2tpEyd9p
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Dmitry,

On Wed, Jul 13, 2022 at 06:03:09PM +0300, dmitry.semenets@xxxxxxxxx wrote:
> diff --git a/tools/libs/vchan/init.c b/tools/libs/vchan/init.c
> index 9195bd3b98..38658f30af 100644
> --- a/tools/libs/vchan/init.c
> +++ b/tools/libs/vchan/init.c
> @@ -259,6 +259,12 @@ static int init_xs_srv(struct libxenvchan *ctrl, int 
> domain, const char* xs_base
>       if (!ctrl->xs_path)
>               return -1; 
>  
> +     buf = malloc(XENSTORE_ABS_PATH_MAX);
> +     if (!buf) {
> +             free(ctrl);
> +             return 0;

I don't understand what you are trying to achieve here. If we can't
allocate `buf`, we should return an error, right?
Also, `ctrl` isn't allocated in this function but by the caller, so I
don't think we need to free it here. Also, if it's free here, the caller
is going to continue to use the pointer, after free.

> +     }
> +
>       xs = xs_open(0);
>       if (!xs)
>               goto fail;
> @@ -419,13 +426,20 @@ struct libxenvchan *libxenvchan_client_init(struct 
> xentoollog_logger *logger,
>  {
>       struct libxenvchan *ctrl = malloc(sizeof(struct libxenvchan));
>       struct xs_handle *xs = NULL;
> -     char buf[64];
> +     char *buf;
>       char *ref;
>       int ring_ref;
>       unsigned int len;
>  
>       if (!ctrl)
>               return 0;
> +
> +     buf = malloc(XENSTORE_ABS_PATH_MAX);
> +     if (!buf) {
> +             free(ctrl);
> +             return 0;

Nit: could you write NULL instead of 0 here? It would makes it much
easier to understand that we return a pointer.


Thanks,

-- 
Anthony PERARD



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.