Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Chen Yisong
lxc
Commits
cebc88c1
Unverified
Commit
cebc88c1
authored
Jun 11, 2018
by
Christian Brauner
Committed by
GitHub
Jun 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2394 from 2xsec/coverity
coverity: #1425747
parents
a810dc80
92838873
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
21 deletions
+20
-21
criu.c
src/lxc/criu.c
+19
-6
lxccontainer.c
src/lxc/lxccontainer.c
+1
-1
monitor.c
src/lxc/monitor.c
+0
-7
lxc_monitor.c
src/lxc/tools/lxc_monitor.c
+0
-7
No files found.
src/lxc/criu.c
View file @
cebc88c1
...
...
@@ -868,14 +868,14 @@ static bool criu_ok(struct lxc_container *c, char **criu_version)
{
struct
lxc_list
*
it
;
if
(
!
criu_version_ok
(
criu_version
))
return
false
;
if
(
geteuid
())
{
ERROR
(
"Must be root to checkpoint"
);
return
false
;
}
if
(
!
criu_version_ok
(
criu_version
))
return
false
;
/* We only know how to restore containers with veth networks. */
lxc_list_for_each
(
it
,
&
c
->
lxc_conf
->
network
)
{
struct
lxc_netdev
*
n
=
it
->
elem
;
...
...
@@ -887,6 +887,10 @@ static bool criu_ok(struct lxc_container *c, char **criu_version)
break
;
default:
ERROR
(
"Found un-dumpable network: %s (%s)"
,
lxc_net_type_to_str
(
n
->
type
),
n
->
name
);
if
(
criu_version
)
{
free
(
*
criu_version
);
*
criu_version
=
NULL
;
}
return
false
;
}
}
...
...
@@ -1239,6 +1243,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
ret
=
pipe
(
criuout
);
if
(
ret
<
0
)
{
SYSERROR
(
"pipe() failed"
);
free
(
criu_version
);
return
false
;
}
...
...
@@ -1299,6 +1304,7 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
if
(
w
==
-
1
)
{
SYSERROR
(
"waitpid"
);
close
(
criuout
[
0
]);
free
(
criu_version
);
return
false
;
}
...
...
@@ -1327,6 +1333,8 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
if
(
!
ret
)
ERROR
(
"criu output: %s"
,
buf
);
free
(
criu_version
);
return
ret
;
}
fail:
...
...
@@ -1366,9 +1374,6 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
int
pipefd
[
2
];
char
*
criu_version
=
NULL
;
if
(
!
criu_ok
(
c
,
&
criu_version
))
return
false
;
if
(
geteuid
())
{
ERROR
(
"Must be root to restore"
);
return
false
;
...
...
@@ -1379,10 +1384,17 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
return
false
;
}
if
(
!
criu_ok
(
c
,
&
criu_version
))
{
close
(
pipefd
[
0
]);
close
(
pipefd
[
1
]);
return
false
;
}
pid
=
fork
();
if
(
pid
<
0
)
{
close
(
pipefd
[
0
]);
close
(
pipefd
[
1
]);
free
(
criu_version
);
return
false
;
}
...
...
@@ -1393,6 +1405,7 @@ bool __criu_restore(struct lxc_container *c, struct migrate_opts *opts)
}
close
(
pipefd
[
1
]);
free
(
criu_version
);
nread
=
read
(
pipefd
[
0
],
&
status
,
sizeof
(
status
));
close
(
pipefd
[
0
]);
...
...
src/lxc/lxccontainer.c
View file @
cebc88c1
...
...
@@ -1384,7 +1384,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath,
ret
=
mount
(
src
,
bdev
->
dest
,
"bind"
,
MS_BIND
|
MS_REC
,
NULL
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to mount rootfs"
);
return
-
1
;
_exit
(
EXIT_FAILURE
)
;
}
}
else
{
ret
=
bdev
->
ops
->
mount
(
bdev
);
...
...
src/lxc/monitor.c
View file @
cebc88c1
...
...
@@ -216,18 +216,11 @@ int lxc_monitor_open(const char *lxcpath)
if
(
lxc_monitor_sock_name
(
lxcpath
,
&
addr
)
<
0
)
return
-
1
;
fd
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
if
(
fd
<
0
)
{
ERROR
(
"Failed to create socket: %s."
,
strerror
(
errno
));
return
-
1
;
}
len
=
strlen
(
&
addr
.
sun_path
[
1
]);
DEBUG
(
"opening monitor socket %s with len %zu"
,
&
addr
.
sun_path
[
1
],
len
);
if
(
len
>=
sizeof
(
addr
.
sun_path
)
-
1
)
{
errno
=
ENAMETOOLONG
;
ERROR
(
"name of monitor socket too long (%zu bytes): %s"
,
len
,
strerror
(
errno
));
close
(
fd
);
return
-
1
;
}
...
...
src/lxc/tools/lxc_monitor.c
View file @
cebc88c1
...
...
@@ -342,16 +342,9 @@ static int lxc_monitor_open(const char *lxcpath)
if
(
lxc_monitor_sock_name
(
lxcpath
,
&
addr
)
<
0
)
return
-
1
;
fd
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Failed to create socket: %s
\n
"
,
strerror
(
errno
));
return
-
errno
;
}
len
=
strlen
(
&
addr
.
sun_path
[
1
]);
if
(
len
>=
sizeof
(
addr
.
sun_path
)
-
1
)
{
errno
=
ENAMETOOLONG
;
close
(
fd
);
fprintf
(
stderr
,
"name of monitor socket too long (%zu bytes): %s
\n
"
,
len
,
strerror
(
errno
));
return
-
errno
;
}
...
...
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