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
f6812e7f
Unverified
Commit
f6812e7f
authored
Dec 07, 2017
by
Serge Hallyn
Committed by
GitHub
Dec 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2011 from brauner/generic/coverity
coverity: bugfixes
parents
fb398f07
2d7bf744
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
17 deletions
+39
-17
attach.c
src/lxc/attach.c
+10
-3
cgfs.c
src/lxc/cgroups/cgfs.c
+4
-1
cgfsng.c
src/lxc/cgroups/cgfsng.c
+2
-0
commands.c
src/lxc/commands.c
+2
-1
confile_legacy.c
src/lxc/confile_legacy.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+5
-3
network.c
src/lxc/network.c
+6
-1
start.c
src/lxc/start.c
+8
-6
lxc_copy.c
src/lxc/tools/lxc_copy.c
+1
-1
No files found.
src/lxc/attach.c
View file @
f6812e7f
...
@@ -599,6 +599,7 @@ static char *lxc_attach_getpwshell(uid_t uid)
...
@@ -599,6 +599,7 @@ static char *lxc_attach_getpwshell(uid_t uid)
if
(
waitpid
(
pid
,
&
status
,
0
)
<
0
)
{
if
(
waitpid
(
pid
,
&
status
,
0
)
<
0
)
{
if
(
errno
==
EINTR
)
if
(
errno
==
EINTR
)
goto
again
;
goto
again
;
free
(
result
);
return
NULL
;
return
NULL
;
}
}
...
@@ -607,14 +608,20 @@ static char *lxc_attach_getpwshell(uid_t uid)
...
@@ -607,14 +608,20 @@ static char *lxc_attach_getpwshell(uid_t uid)
* don't.
* don't.
*/
*/
if
(
!
WIFEXITED
(
status
))
if
(
!
WIFEXITED
(
status
))
{
free
(
result
);
return
NULL
;
return
NULL
;
}
if
(
WEXITSTATUS
(
status
)
!=
0
)
if
(
WEXITSTATUS
(
status
)
!=
0
)
{
free
(
result
);
return
NULL
;
return
NULL
;
}
if
(
!
found
)
if
(
!
found
)
{
free
(
result
);
return
NULL
;
return
NULL
;
}
return
result
;
return
result
;
}
else
{
}
else
{
...
...
src/lxc/cgroups/cgfs.c
View file @
f6812e7f
...
@@ -555,7 +555,10 @@ static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char **
...
@@ -555,7 +555,10 @@ static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char **
}
}
}
}
k
=
lxc_array_len
((
void
**
)
h
->
all_mount_points
);
if
(
h
)
k
=
lxc_array_len
((
void
**
)
h
->
all_mount_points
);
else
k
=
0
;
r
=
lxc_grow_array
((
void
***
)
&
h
->
all_mount_points
,
&
h
->
all_mount_point_capacity
,
k
+
1
,
4
);
r
=
lxc_grow_array
((
void
***
)
&
h
->
all_mount_points
,
&
h
->
all_mount_point_capacity
,
k
+
1
,
4
);
if
(
r
<
0
)
if
(
r
<
0
)
goto
out
;
goto
out
;
...
...
src/lxc/cgroups/cgfsng.c
View file @
f6812e7f
...
@@ -526,6 +526,7 @@ static bool filter_and_set_cpus(char *path, bool am_initialized)
...
@@ -526,6 +526,7 @@ static bool filter_and_set_cpus(char *path, bool am_initialized)
copy_parent:
copy_parent:
*
lastslash
=
oldv
;
*
lastslash
=
oldv
;
free
(
fpath
);
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
ret
=
lxc_write_to_file
(
fpath
,
cpulist
,
strlen
(
cpulist
),
false
);
ret
=
lxc_write_to_file
(
fpath
,
cpulist
,
strlen
(
cpulist
),
false
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -1748,6 +1749,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
...
@@ -1748,6 +1749,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
path2
=
must_make_path
(
controllerpath
,
h
->
base_cgroup
,
d
->
container_cgroup
,
NULL
);
path2
=
must_make_path
(
controllerpath
,
h
->
base_cgroup
,
d
->
container_cgroup
,
NULL
);
if
(
mkdir_p
(
path2
,
0755
)
<
0
)
{
if
(
mkdir_p
(
path2
,
0755
)
<
0
)
{
free
(
controllerpath
);
free
(
controllerpath
);
free
(
path2
);
goto
bad
;
goto
bad
;
}
}
...
...
src/lxc/commands.c
View file @
f6812e7f
...
@@ -325,7 +325,8 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
...
@@ -325,7 +325,8 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
*
stopped
=
1
;
*
stopped
=
1
;
out:
out:
if
(
!
stay_connected
||
ret
<=
0
)
if
(
!
stay_connected
||
ret
<=
0
)
close
(
client_fd
);
if
(
client_fd
>=
0
)
close
(
client_fd
);
if
(
stay_connected
&&
ret
>
0
)
if
(
stay_connected
&&
ret
>
0
)
cmd
->
rsp
.
ret
=
client_fd
;
cmd
->
rsp
.
ret
=
client_fd
;
...
...
src/lxc/confile_legacy.c
View file @
f6812e7f
...
@@ -975,7 +975,7 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
...
@@ -975,7 +975,7 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
if
(
!
p1
||
*
(
p1
+
1
)
==
'\0'
)
if
(
!
p1
||
*
(
p1
+
1
)
==
'\0'
)
return
-
1
;
return
-
1
;
if
(
!
p1
&&
it
)
{
if
(
it
)
{
lxc_remove_nic
(
it
);
lxc_remove_nic
(
it
);
}
else
if
(
strcmp
(
p1
,
".ipv4"
)
==
0
)
{
}
else
if
(
strcmp
(
p1
,
".ipv4"
)
==
0
)
{
struct
lxc_list
*
it2
,
*
next
;
struct
lxc_list
*
it2
,
*
next
;
...
...
src/lxc/lxccontainer.c
View file @
f6812e7f
...
@@ -848,10 +848,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -848,10 +848,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
/* ... otherwise use default_args. */
/* ... otherwise use default_args. */
if
(
!
argv
)
{
if
(
!
argv
)
{
if
(
useinit
)
if
(
useinit
)
{
ERROR
(
"No valid init detected"
);
lxc_free_handler
(
handler
);
return
false
;
return
false
;
else
}
argv
=
default_args
;
argv
=
default_args
;
}
}
/* I'm not sure what locks we want here.Any? Is liblxc's locking enough
/* I'm not sure what locks we want here.Any? Is liblxc's locking enough
...
...
src/lxc/network.c
View file @
f6812e7f
...
@@ -1915,6 +1915,7 @@ static const char padchar[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
...
@@ -1915,6 +1915,7 @@ static const char padchar[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char
*
lxc_mkifname
(
char
*
template
)
char
*
lxc_mkifname
(
char
*
template
)
{
{
int
ret
;
unsigned
int
seed
;
unsigned
int
seed
;
FILE
*
urandom
;
FILE
*
urandom
;
struct
ifaddrs
*
ifa
,
*
ifaddr
;
struct
ifaddrs
*
ifa
,
*
ifaddr
;
...
@@ -1926,7 +1927,11 @@ char *lxc_mkifname(char *template)
...
@@ -1926,7 +1927,11 @@ char *lxc_mkifname(char *template)
return
NULL
;
return
NULL
;
/* Get all the network interfaces. */
/* Get all the network interfaces. */
getifaddrs
(
&
ifaddr
);
ret
=
getifaddrs
(
&
ifaddr
);
if
(
ret
<
0
)
{
ERROR
(
"%s - Failed to get network interfaces"
,
strerror
(
errno
));
return
NULL
;
}
/* Initialize the random number generator. */
/* Initialize the random number generator. */
urandom
=
fopen
(
"/dev/urandom"
,
"r"
);
urandom
=
fopen
(
"/dev/urandom"
,
"r"
);
...
...
src/lxc/start.c
View file @
f6812e7f
...
@@ -226,14 +226,16 @@ restart:
...
@@ -226,14 +226,16 @@ restart:
continue
;
continue
;
/* Keep state clients that wait on reboots. */
/* Keep state clients that wait on reboots. */
lxc_list_for_each
(
cur
,
&
conf
->
state_clients
)
{
if
(
conf
)
{
struct
lxc_state_client
*
client
=
cur
->
elem
;
lxc_list_for_each
(
cur
,
&
conf
->
state_clients
)
{
struct
lxc_state_client
*
client
=
cur
->
elem
;
if
(
client
->
clientfd
!=
fd
)
if
(
client
->
clientfd
!=
fd
)
continue
;
continue
;
matched
=
true
;
matched
=
true
;
break
;
break
;
}
}
}
if
(
matched
)
if
(
matched
)
...
...
src/lxc/tools/lxc_copy.c
View file @
f6812e7f
...
@@ -417,7 +417,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
...
@@ -417,7 +417,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
if
(
!
mkdtemp
(
randname
))
if
(
!
mkdtemp
(
randname
))
return
-
1
;
return
-
1
;
if
(
chmod
(
randname
,
0770
)
<
0
)
{
if
(
chmod
(
randname
,
0770
)
<
0
)
{
remove
(
randname
);
(
void
)
remove
(
randname
);
return
-
1
;
return
-
1
;
}
}
arg
->
newname
=
randname
+
strlen
(
arg
->
newpath
)
+
1
;
arg
->
newname
=
randname
+
strlen
(
arg
->
newpath
)
+
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