[CRIU] [PATCH] tty: prefer zalloc to malloc for inverted_path allocation

Cyrill Gorcunov gorcunov at gmail.com
Thu Jun 23 04:12:16 PDT 2016


On Thu, Jun 23, 2016 at 02:00:12PM +0300, Dmitry Safonov wrote:
> Otherwise, we copy original name to slash and after it there may stay
> some junk, which strcat will use for concatenation:
> (00.024843)     26: Error (files-reg.c:1528): Can't open file dev/pts/g:��ptmx on restore: No such file or directory
> (00.024846)     26: Error (files-reg.c:1470): Can't open file dev/pts/g:��ptmx: No such file or directory
> (00.024849)     26: Error (tty.c:545): tty: Can't open dev/pts/g:��ptmx: No such file or directory
> 
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>

That's big hammer, won't the below oneliner fix it?
---
diff --git a/criu/tty.c b/criu/tty.c
index 328fafe..0a535a9 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -477,6 +477,7 @@ static struct reg_file_info *pty_alloc_fake_reg(struct tty_info *info, int subty
 
                memcpy(inverted_path, orig->rfe->name, slash_at + 1);
                if (subtype == TTY_SUBTYPE_MASTER)
+                       inverted_path[slash_at + 1] = '\0';
                        strcat(inverted_path, "ptmx");
                else {
                        if (slash_at >= 3 && strncmp(&inverted_path[slash_at - 3], "pts", 3))




More information about the CRIU mailing list