Patchwork inet_parse: fix ,to= parsing

login
register
mail settings
Submitter Stefano Stabellini
Date Nov. 21, 2012, 6:28 p.m.
Message ID <alpine.DEB.2.02.1211211655440.13749@kaball.uk.xensource.com>
Download mbox | patch
Permalink /patch/200821/
State New
Headers show

Comments

Stefano Stabellini - Nov. 21, 2012, 6:28 p.m.
Fix inet_parse to parse the ",to=" command line option correctly.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Markus Armbruster - Nov. 22, 2012, 8:29 a.m.
Stefano Stabellini <stefano.stabellini@eu.citrix.com> writes:

> Fix inet_parse to parse the ",to=" command line option correctly.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> diff --git a/qemu-sockets.c b/qemu-sockets.c
> index cfed9c5..f8740dd 100644
> --- a/qemu-sockets.c
> +++ b/qemu-sockets.c
> @@ -529,8 +529,9 @@ static InetSocketAddress *inet_parse(const char *str, Error **errp)
>      optstr = str + pos;
>      h = strstr(optstr, ",to=");
>      if (h) {
> -        if (1 != sscanf(str, "%d%n", &to, &pos) ||
> -            (str[pos] != '\0' && str[pos] != ',')) {
> +        h += 4;
> +        if (1 != sscanf(h, "%d%n", &to, &pos) ||
> +            (h[pos] != '\0' && h[pos] != ',')) {
>              error_setg(errp, "error parsing to= argument");
>              goto fail;
>          }

Similar patch just got committed as 1ccbc285.  Thanks anyway!

Patch

diff --git a/qemu-sockets.c b/qemu-sockets.c
index cfed9c5..f8740dd 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -529,8 +529,9 @@  static InetSocketAddress *inet_parse(const char *str, Error **errp)
     optstr = str + pos;
     h = strstr(optstr, ",to=");
     if (h) {
-        if (1 != sscanf(str, "%d%n", &to, &pos) ||
-            (str[pos] != '\0' && str[pos] != ',')) {
+        h += 4;
+        if (1 != sscanf(h, "%d%n", &to, &pos) ||
+            (h[pos] != '\0' && h[pos] != ',')) {
             error_setg(errp, "error parsing to= argument");
             goto fail;
         }