[CRIU] [PATCH] tty: Fix path inversion for /dev/pts/ptmx

Cyrill Gorcunov gorcunov at gmail.com
Thu Oct 23 11:00:26 PDT 2014


On Thu, Oct 23, 2014 at 09:56:47PM +0400, Pavel Emelyanov wrote:
> On 10/23/2014 09:43 PM, Cyrill Gorcunov wrote:
> > Need to compare the /pts/ part in the
> > former path, otherwise it will produce
> > bogus /dev/pts/pts/index form.
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> > ---
> >  tty.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tty.c b/tty.c
> > index 276bd284aa43..66f969b4cb60 100644
> > --- a/tty.c
> > +++ b/tty.c
> > @@ -332,7 +332,7 @@ static struct reg_file_info *pty_alloc_fake_reg(struct tty_info *info, int type)
> >  		if (type == TTY_TYPE_PTM)
> >  			strcat(inverted_path, "ptmx");
> >  		else {
> > -			if (slash_at >= 4 && strcmp(&inverted_path[slash_at - 4], "pts"))
> > +			if (slash_at >= 3 && strcmp(&inverted_path[slash_at - 3], "pts", 3))
> 
> How did you test it? The strcmp takes only 2 args.

Sigh. Sorry, I've fixed it on the remote copy of the repo
but managed to miss pulling the changes. Here is an update.
Thanks, and sorry again.
-------------- next part --------------
>From 9402b4da6a6004a57780e224e98e07b907f436d9 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 23 Oct 2014 21:42:29 +0400
Subject: [PATCH] tty: Fix path inversion for /dev/pts/ptmx

Need to compare the /pts/ part in the
former path, otherwise it will produce
bogus /dev/pts/pts/index form.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tty.c b/tty.c
index 276bd284aa43..949694f33c39 100644
--- a/tty.c
+++ b/tty.c
@@ -332,7 +332,7 @@ static struct reg_file_info *pty_alloc_fake_reg(struct tty_info *info, int type)
 		if (type == TTY_TYPE_PTM)
 			strcat(inverted_path, "ptmx");
 		else {
-			if (slash_at >= 4 && strcmp(&inverted_path[slash_at - 4], "pts"))
+			if (slash_at >= 3 && strncmp(&inverted_path[slash_at - 3], "pts", 3))
 				snprintf(&inverted_path[slash_at + 1], 10, "pts/%u",
 					 info->tie->pty->index);
 			else
-- 
1.9.3



More information about the CRIU mailing list