qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Sage Weil <sage@newdream.net>
Cc: ceph-devel@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/4] rbd: allow escaping in config string
Date: Mon, 19 Sep 2011 16:06:17 +0200	[thread overview]
Message-ID: <4E774C59.3070401@redhat.com> (raw)
In-Reply-To: <1316121071-7690-3-git-send-email-sage@newdream.net>

Am 15.09.2011 23:11, schrieb Sage Weil:
> The config string is variously delimited by =, @, and /, depending on the
> field.  Allow these characters to be escaped by preceeding them with \.
> 
> Signed-off-by: Sage Weil <sage@newdream.net>
> ---
>  block/rbd.c |   29 +++++++++++++++++++++++++++--
>  1 files changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index f64b2e0..43f0e63 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -104,8 +104,15 @@ static int qemu_rbd_next_tok(char *dst, int dst_len,
>      *p = NULL;
>  
>      if (delim != '\0') {
> -        end = strchr(src, delim);
> -        if (end) {
> +        for (end = src; *end; ++end) {
> +            if (*end == delim) {
> +                break;
> +            }
> +            if (*end == '\\') {
> +                end++;
> +            }
> +        }

If src ends with a backslash, you read beyond the end of the string.

> +        if (*end == delim) {
>              *p = end + 1;
>              *end = '\0';
>          }
> @@ -124,6 +131,19 @@ static int qemu_rbd_next_tok(char *dst, int dst_len,
>      return 0;
>  }
>  
> +static void qemu_rbd_unescape(char *src)
> +{
> +    char *p;
> +
> +    for (p = src; *src; ++src, ++p) {
> +        if (*src == '\\') {
> +            src++;
> +        }
> +        *p = *src;
> +    }
> +    *p = '\0';
> +}

This has the same problem.

Wouldn't it make sense to have the unescape integrated in
qemu_rbd_next_tok? Or are there any places where you would want to call
it without doing a qemu_rbd_unescape() afterwards?

Kevin

  reply	other threads:[~2011-09-19 14:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 21:11 [Qemu-devel] [PATCH 0/4] More RBD updates Sage Weil
2011-09-15 21:11 ` [Qemu-devel] [PATCH 1/4] rbd: ignore failures when reading from default conf location Sage Weil
2011-09-15 21:11 ` [Qemu-devel] [PATCH 2/4] rbd: allow escaping in config string Sage Weil
2011-09-19 14:06   ` Kevin Wolf [this message]
2011-09-19 20:33     ` Sage Weil
2011-09-15 21:11 ` [Qemu-devel] [PATCH 3/4] rbd: update comment heading Sage Weil
2011-09-15 21:11 ` [Qemu-devel] [PATCH 4/4] rbd: call flush, if available Sage Weil
2011-09-19 14:09 ` [Qemu-devel] [PATCH 0/4] More RBD updates Kevin Wolf

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=4E774C59.3070401@redhat.com \
    --to=kwolf@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sage@newdream.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).