Patchwork fix wrong output with 'info chardev' for tcp socket.

login
register
mail settings
Submitter Serge E. Hallyn
Date Feb. 21, 2013, 8:20 p.m.
Message ID <20130221202028.GA2302@mail.hallyn.com>
Download mbox | patch
Permalink /patch/222410/
State New
Headers show

Comments

Serge E. Hallyn - Feb. 21, 2013, 8:20 p.m.
The snprintf format isn't taking into account the new 'left' and
'right' variables (for ipv6 []) when placing the ':', which should
go immediately before the port.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
---
 qemu-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Michael Tokarev - Feb. 21, 2013, 8:29 p.m.
22.02.2013 00:20, Serge E. Hallyn wrote:
> The snprintf format isn't taking into account the new 'left' and
> 'right' variables (for ipv6 []) when placing the ':', which should
> go immediately before the port.

This fixes actual isse (also found by Serge), where `info chardev'
prints `tcp:127.0.0.14444,server,nowait' for a monitor running on port
4444.

This is definitely a stable material (CCed).

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

Thanks!

/mjt

> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> ---
>  qemu-char.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index e4b0f53..3e152e1 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -2482,7 +2482,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
>          s->do_nodelay = do_nodelay;
>          getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
>                      serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
> -        snprintf(chr->filename, 256, "%s:%s:%s%s%s%s",
> +        snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
>                   is_telnet ? "telnet" : "tcp",
>                   left, host, right, serv,
>                   is_listen ? ",server" : "");
>
Michael Roth - Feb. 21, 2013, 10:28 p.m.
On Fri, Feb 22, 2013 at 12:29:44AM +0400, Michael Tokarev wrote:
> 22.02.2013 00:20, Serge E. Hallyn wrote:
> > The snprintf format isn't taking into account the new 'left' and
> > 'right' variables (for ipv6 []) when placing the ':', which should
> > go immediately before the port.
> 
> This fixes actual isse (also found by Serge), where `info chardev'
> prints `tcp:127.0.0.14444,server,nowait' for a monitor running on port
> 4444.
> 
> This is definitely a stable material (CCed).
> 
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> 
> Thanks!
> 
> /mjt
> 
> > Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> > ---
> >  qemu-char.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/qemu-char.c b/qemu-char.c
> > index e4b0f53..3e152e1 100644
> > --- a/qemu-char.c
> > +++ b/qemu-char.c
> > @@ -2482,7 +2482,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
> >          s->do_nodelay = do_nodelay;
> >          getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
> >                      serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
> > -        snprintf(chr->filename, 256, "%s:%s:%s%s%s%s",
> > +        snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
> >                   is_telnet ? "telnet" : "tcp",
> >                   left, host, right, serv,
> >                   is_listen ? ",server" : "");
> > 
> 
>
Michael Roth - April 2, 2013, 3:26 p.m.
On Thu, Feb 21, 2013 at 04:28:27PM -0600, mdroth wrote:
> On Fri, Feb 22, 2013 at 12:29:44AM +0400, Michael Tokarev wrote:
> > 22.02.2013 00:20, Serge E. Hallyn wrote:
> > > The snprintf format isn't taking into account the new 'left' and
> > > 'right' variables (for ipv6 []) when placing the ':', which should
> > > go immediately before the port.
> > 
> > This fixes actual isse (also found by Serge), where `info chardev'
> > prints `tcp:127.0.0.14444,server,nowait' for a monitor running on port
> > 4444.
> > 
> > This is definitely a stable material (CCed).

Fix made it upstream through a separate patch:

ec9f828341cb5e9cc3ad0bdbbd6989884daf823a

> > 
> > Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
> 
> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> 
> > 
> > Thanks!
> > 
> > /mjt
> > 
> > > Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> > > ---
> > >  qemu-char.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/qemu-char.c b/qemu-char.c
> > > index e4b0f53..3e152e1 100644
> > > --- a/qemu-char.c
> > > +++ b/qemu-char.c
> > > @@ -2482,7 +2482,7 @@ static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
> > >          s->do_nodelay = do_nodelay;
> > >          getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
> > >                      serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
> > > -        snprintf(chr->filename, 256, "%s:%s:%s%s%s%s",
> > > +        snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
> > >                   is_telnet ? "telnet" : "tcp",
> > >                   left, host, right, serv,
> > >                   is_listen ? ",server" : "");
> > > 
> > 
> >

Patch

diff --git a/qemu-char.c b/qemu-char.c
index e4b0f53..3e152e1 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2482,7 +2482,7 @@  static CharDriverState *qemu_chr_open_socket_fd(int fd, bool do_nodelay,
         s->do_nodelay = do_nodelay;
         getnameinfo((struct sockaddr *) &ss, ss_len, host, sizeof(host),
                     serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
-        snprintf(chr->filename, 256, "%s:%s:%s%s%s%s",
+        snprintf(chr->filename, 256, "%s:%s%s%s:%s%s",
                  is_telnet ? "telnet" : "tcp",
                  left, host, right, serv,
                  is_listen ? ",server" : "");