qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs
@ 2010-06-08 11:54 Markus Armbruster
  2010-06-14 20:57 ` Anthony Liguori
  2010-06-22  9:33 ` Avi Kivity
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Armbruster @ 2010-06-08 11:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

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>
---
 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) {
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs
  2010-06-08 11:54 [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs Markus Armbruster
@ 2010-06-14 20:57 ` Anthony Liguori
  2010-06-22  9:33 ` Avi Kivity
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2010-06-14 20:57 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, kraxel

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) {
>    

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs
  2010-06-08 11:54 [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs Markus Armbruster
  2010-06-14 20:57 ` Anthony Liguori
@ 2010-06-22  9:33 ` Avi Kivity
  1 sibling, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2010-06-22  9:33 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, kraxel

On 06/08/2010 02:54 PM, Markus Armbruster wrote:
> Restrict IDs to letters, digits, '-', '.', '_', starting with a
> letter.
>
> This takes care of '/' in qdev IDs breaking qbus_find().
>
>    

Broke autotest (used leading numeric char).  Patch posted.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-22  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-08 11:54 [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs Markus Armbruster
2010-06-14 20:57 ` Anthony Liguori
2010-06-22  9:33 ` Avi Kivity

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).