All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: PRAMOD DEVENDRA <pramod.devendra@citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 1/3] tools/libxl/libxl_qmp.c: Make sure sun_path is NULL terminated in qmp_open
Date: Tue, 17 Mar 2015 15:42:08 +0000	[thread overview]
Message-ID: <20150317154207.GB20522@zion.uk.xensource.com> (raw)
In-Reply-To: <1426500338-36798-1-git-send-email-pramod.devendra@citrix.com>

On Mon, Mar 16, 2015 at 10:05:38AM +0000, PRAMOD DEVENDRA wrote:
> From: Pramod Devendra <pramod.devendra@citrix.com>
> 
> Signed-off-by: Pramod Devendra <pramod.devendra@citrix.com>
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: Ian Campbell <ian.campbell@citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxl/libxl_qmp.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> index c7324e6..1080162 100644
> --- a/tools/libxl/libxl_qmp.c
> +++ b/tools/libxl/libxl_qmp.c
> @@ -369,10 +369,13 @@ static int qmp_open(libxl__qmp_handler *qmp, const char *qmp_socket_path,
>      ret = libxl_fd_set_cloexec(qmp->ctx, qmp->qmp_fd, 1);
>      if (ret) return -1;
>  
> +    if(sizeof (qmp->addr.sun_path) <= strlen(qmp_socket_path))
> +        return -1;
> +

I know this is not your fault, but the function seems to leak qmp_fd on
error path (qmp_fd is not closed). Do you fancy fixing that?

Wei.

>      memset(&qmp->addr, 0, sizeof (qmp->addr));
>      qmp->addr.sun_family = AF_UNIX;
>      strncpy(qmp->addr.sun_path, qmp_socket_path,
> -            sizeof (qmp->addr.sun_path));
> +            sizeof (qmp->addr.sun_path)-1);
>  
>      do {
>          ret = connect(qmp->qmp_fd, (struct sockaddr *) &qmp->addr,
> -- 
> 1.7.10.4

  reply	other threads:[~2015-03-17 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 10:05 [PATCH 1/3] tools/libxl/libxl_qmp.c: Make sure sun_path is NULL terminated in qmp_open PRAMOD DEVENDRA
2015-03-17 15:42 ` Wei Liu [this message]
2015-03-18 10:04 ` Ian Campbell
2015-03-19  6:40 ` [PATCH v2] libxl/libxl_qmp.c: fix qmp_open PRAMOD DEVENDRA
2015-03-19 10:03   ` Wei Liu
2015-03-19 10:51     ` Ian Campbell
2015-03-19 12:55   ` [PATCH v3] libxl/libxl_qmp.c: fix error handling in qmp_open PRAMOD DEVENDRA
2015-03-20 10:08     ` Wei Liu
2015-03-20 11:56       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150317154207.GB20522@zion.uk.xensource.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=pramod.devendra@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.