All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs
Date: Mon, 14 Jun 2010 15:57:24 -0500	[thread overview]
Message-ID: <4C1697B4.3030402@codemonkey.ws> (raw)
In-Reply-To: <1275998066-2796-1-git-send-email-armbru@redhat.com>

On 06/08/2010 06:54 AM, Markus Armbruster wrote:
> Restrict IDs to letters, digits, '-', '.', '_', starting with a
> letter.
>
> This takes care of '/' in qdev IDs breaking qbus_find().
>
> Signed-off-by: Markus Armbruster<armbru@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   qemu-option.c |   20 ++++++++++++++++++++
>   1 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-option.c b/qemu-option.c
> index acd74f9..74fb882 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -672,11 +672,31 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
>       return NULL;
>   }
>
> +static int id_wellformed(const char *id)
> +{
> +    int i;
> +
> +    if (!qemu_isalpha(id[0])) {
> +        return 0;
> +    }
> +    for (i = 1; id[i]; i++) {
> +        if (!qemu_isalnum(id[i])&&  !strchr("-._", id[i])) {
> +            return 0;
> +        }
> +    }
> +    return 1;
> +}
> +
>   QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists)
>   {
>       QemuOpts *opts = NULL;
>
>       if (id) {
> +        if (!id_wellformed(id)) {
> +            qerror_report(QERR_INVALID_PARAMETER_VALUE, "id", "an identifier");
> +            error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n");
> +            return NULL;
> +        }
>           opts = qemu_opts_find(list, id);
>           if (opts != NULL) {
>               if (fail_if_exists) {
>    

  reply	other threads:[~2010-06-14 20:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 11:54 [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori [this message]
2010-06-22  9:33 ` Avi Kivity

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=4C1697B4.3030402@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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.