Commit 245b4b36 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

files: Don't access value from stack in outer contex

The struct fd_link link allocated in inner context might be
freed before dump call (depending on compiler), instead
use a safer approach.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e3311ea3
......@@ -407,8 +407,11 @@ static const struct fdtype_ops *get_mem_dev_ops(struct fd_parms *p, int minor)
static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
{
struct fd_link *link_old = p->link;
int maj = major(p->stat.st_rdev);
const struct fdtype_ops *ops;
struct fd_link link;
int err;
switch (maj) {
case MEM_MAJOR:
......@@ -423,8 +426,6 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
char more[32];
if (is_tty(p->stat.st_rdev, p->stat.st_dev)) {
struct fd_link link;
if (fill_fdlink(lfd, p, &link))
return -1;
p->link = &link;
......@@ -433,11 +434,15 @@ static int dump_chrdev(struct fd_parms *p, int lfd, struct cr_img *img)
}
sprintf(more, "%d:%d", maj, minor(p->stat.st_rdev));
return dump_unsupp_fd(p, lfd, img, "chr", more);
err = dump_unsupp_fd(p, lfd, img, "chr", more);
p->link = link_old;
return err;
}
}
return do_dump_gen_file(p, lfd, ops, img);
err = do_dump_gen_file(p, lfd, ops, img);
p->link = link_old;
return err;
}
static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment