Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
7ede4697
Commit
7ede4697
authored
Mar 10, 2015
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bfd: Don't leak image-open flags into bfdopen
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
f7f76d6b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
10 deletions
+28
-10
bfd.c
bfd.c
+13
-3
image.c
image.c
+8
-1
bfd.h
include/bfd.h
+3
-2
proc_parse.c
proc_parse.c
+4
-4
No files found.
bfd.c
View file @
7ede4697
...
...
@@ -87,17 +87,27 @@ static void buf_put(struct xbuf *xb)
xb
->
data
=
NULL
;
}
int
bfdopen
(
struct
bfd
*
f
,
int
mod
e
)
static
int
bfdopen
(
struct
bfd
*
f
,
bool
writabl
e
)
{
if
(
buf_get
(
&
f
->
b
))
{
close
(
f
->
fd
);
return
-
1
;
}
f
->
mode
=
mod
e
;
f
->
writable
=
writabl
e
;
return
0
;
}
int
bfdopenr
(
struct
bfd
*
f
)
{
return
bfdopen
(
f
,
false
);
}
int
bfdopenw
(
struct
bfd
*
f
)
{
return
bfdopen
(
f
,
true
);
}
static
int
bflush
(
struct
bfd
*
bfd
);
static
bool
flush_failed
=
false
;
...
...
@@ -109,7 +119,7 @@ int bfd_flush_images(void)
void
bclose
(
struct
bfd
*
f
)
{
if
(
bfd_buffered
(
f
))
{
if
(
(
f
->
mode
!=
O_RDONLY
)
&&
bflush
(
f
)
<
0
)
{
if
(
f
->
writable
&&
bflush
(
f
)
<
0
)
{
/*
* This is to propagate error up. It's
* hardly possible by returning and
...
...
image.c
View file @
7ede4697
...
...
@@ -239,8 +239,15 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
img
->
_x
.
fd
=
ret
;
if
(
oflags
&
O_NOBUF
)
bfd_setraw
(
&
img
->
_x
);
else
if
(
bfdopen
(
&
img
->
_x
,
flags
))
else
{
if
(
flags
==
O_RDONLY
)
ret
=
bfdopenr
(
&
img
->
_x
);
else
ret
=
bfdopenw
(
&
img
->
_x
);
if
(
ret
)
goto
err_close
;
}
if
(
imgset_template
[
type
].
magic
==
RAW_IMAGE_MAGIC
)
goto
skip_magic
;
...
...
include/bfd.h
View file @
7ede4697
...
...
@@ -13,7 +13,7 @@ struct xbuf {
struct
bfd
{
int
fd
;
int
mod
e
;
bool
writabl
e
;
struct
xbuf
b
;
};
...
...
@@ -27,7 +27,8 @@ static inline void bfd_setraw(struct bfd *b)
b
->
b
.
mem
=
NULL
;
}
int
bfdopen
(
struct
bfd
*
f
,
int
mode
);
int
bfdopenr
(
struct
bfd
*
f
);
int
bfdopenw
(
struct
bfd
*
f
);
void
bclose
(
struct
bfd
*
f
);
char
*
breadline
(
struct
bfd
*
f
);
int
bwrite
(
struct
bfd
*
f
,
const
void
*
buf
,
int
sz
);
...
...
proc_parse.c
View file @
7ede4697
...
...
@@ -358,7 +358,7 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list)
if
(
f
.
fd
<
0
)
goto
err_n
;
if
(
bfdopen
(
&
f
,
O_RDONLY
))
if
(
bfdopen
r
(
&
f
))
goto
err_n
;
map_files_dir
=
opendir_proc
(
pid
,
"map_files"
);
...
...
@@ -733,7 +733,7 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
return
-
1
;
}
if
(
bfdopen
(
&
f
,
O_RDONLY
))
if
(
bfdopen
r
(
&
f
))
return
-
1
;
while
(
done
<
8
&&
(
str
=
breadline
(
&
f
)))
{
...
...
@@ -1165,7 +1165,7 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
return
-
1
;
}
if
(
bfdopen
(
&
f
,
O_RDONLY
))
if
(
bfdopen
r
(
&
f
))
return
-
1
;
while
(
1
)
{
...
...
@@ -1616,7 +1616,7 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
return
-
1
;
}
if
(
bfdopen
(
&
f
,
O_RDONLY
))
if
(
bfdopen
r
(
&
f
))
return
-
1
;
while
(
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment