diff mbox

[v2,14/14] QemuOpts: correctly skip escaped , id=

Message ID 1334180081-6172-15-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini April 11, 2012, 9:34 p.m. UTC
QemuOpts would parse incorrectly something that included ",,id=" (with an
escaped comma) in a parameter value.  Fix this by using get_param_value.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-option.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

Comments

Anthony Liguori April 25, 2012, 9:05 p.m. UTC | #1
On 04/11/2012 04:34 PM, Paolo Bonzini wrote:
> QemuOpts would parse incorrectly something that included ",,id=" (with an
> escaped comma) in a parameter value.  Fix this by using get_param_value.
>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

This breaks qemu-test.  Specifically:

out=`hmp netdev_add user,id=foo`

Fails with an error in QemuOpts parsing.

Regards,

Anthony Liguori

> ---
>   qemu-option.c |    7 +------
>   1 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/qemu-option.c b/qemu-option.c
> index 7a89eeb..63759b0 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -864,17 +864,12 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
>   {
>       const char *firstname;
>       char value[1024], *id = NULL;
> -    const char *p;
>       QemuOpts *opts;
>
>       assert(!permit_abbrev || list->implied_opt_name);
>       firstname = permit_abbrev ? list->implied_opt_name : NULL;
>
> -    if (strncmp(params, "id=", 3) == 0) {
> -        get_opt_value(value, sizeof(value), params+3);
> -        id = value;
> -    } else if ((p = strstr(params, ",id=")) != NULL) {
> -        get_opt_value(value, sizeof(value), p+4);
> +    if (get_param_value(value, sizeof(value), "id", params)) {
>           id = value;
>       }
>       if (defaults) {
Paolo Bonzini April 26, 2012, 4:56 p.m. UTC | #2
> This breaks qemu-test.  Specifically:
> 
> out=`hmp netdev_add user,id=foo`
> 
> Fails with an error in QemuOpts parsing.

Ok, I'll take a look and work on top of Luiz's netdev patches
when I come back from holiday.

Are you applying the non-problematic patches to 1.1, or even
only the first 11?

Paolo
Anthony Liguori April 26, 2012, 6:03 p.m. UTC | #3
On 04/26/2012 11:56 AM, Paolo Bonzini wrote:
>> This breaks qemu-test.  Specifically:
>>
>> out=`hmp netdev_add user,id=foo`
>>
>> Fails with an error in QemuOpts parsing.
>
> Ok, I'll take a look and work on top of Luiz's netdev patches
> when I come back from holiday.
>
> Are you applying the non-problematic patches to 1.1, or even
> only the first 11?

I had tried to do a subset of them but I ran into another SEGV.  I ended up 
dropping them.

If I get some time, I'll try to test again and find a working subset.

Regards,

Anthony Liguori

>
> Paolo
Paolo Bonzini April 26, 2012, 7:07 p.m. UTC | #4
Il 26/04/2012 20:03, Anthony Liguori ha scritto:
>>
>> Ok, I'll take a look and work on top of Luiz's netdev patches
>> when I come back from holiday.
>>
>> Are you applying the non-problematic patches to 1.1, or even
>> only the first 11?
> 
> I had tried to do a subset of them but I ran into another SEGV.  I ended
> up dropping them.
> 
> If I get some time, I'll try to test again and find a working subset.

Since my time is also (voluntarily :)) limited, let's postpone to 1.2.
You have enough work...

Paolo
diff mbox

Patch

diff --git a/qemu-option.c b/qemu-option.c
index 7a89eeb..63759b0 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -864,17 +864,12 @@  static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
 {
     const char *firstname;
     char value[1024], *id = NULL;
-    const char *p;
     QemuOpts *opts;
 
     assert(!permit_abbrev || list->implied_opt_name);
     firstname = permit_abbrev ? list->implied_opt_name : NULL;
 
-    if (strncmp(params, "id=", 3) == 0) {
-        get_opt_value(value, sizeof(value), params+3);
-        id = value;
-    } else if ((p = strstr(params, ",id=")) != NULL) {
-        get_opt_value(value, sizeof(value), p+4);
+    if (get_param_value(value, sizeof(value), "id", params)) {
         id = value;
     }
     if (defaults) {