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
ef95dc01
Commit
ef95dc01
authored
Feb 19, 2016
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #826 from brauner/2016-02-19/exec_cast_null
cast NULL pointers passed to execl*()
parents
d89da6bf
acf47e1b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
28 deletions
+28
-28
attach.c
src/lxc/attach.c
+2
-2
bdev.c
src/lxc/bdev/bdev.c
+1
-1
lxclvm.c
src/lxc/bdev/lxclvm.c
+1
-1
lxcnbd.c
src/lxc/bdev/lxcnbd.c
+2
-2
lxcrbd.c
src/lxc/bdev/lxcrbd.c
+4
-4
lxczfs.c
src/lxc/bdev/lxczfs.c
+6
-6
network.c
src/lxc/network.c
+12
-12
No files found.
src/lxc/attach.c
View file @
ef95dc01
...
@@ -1252,12 +1252,12 @@ int lxc_attach_run_shell(void* payload)
...
@@ -1252,12 +1252,12 @@ int lxc_attach_run_shell(void* payload)
user_shell
=
passwd
->
pw_shell
;
user_shell
=
passwd
->
pw_shell
;
if
(
user_shell
)
if
(
user_shell
)
execlp
(
user_shell
,
user_shell
,
NULL
);
execlp
(
user_shell
,
user_shell
,
(
char
*
)
NULL
);
/* executed if either no passwd entry or execvp fails,
/* executed if either no passwd entry or execvp fails,
* we will fall back on /bin/sh as a default shell
* we will fall back on /bin/sh as a default shell
*/
*/
execlp
(
"/bin/sh"
,
"/bin/sh"
,
NULL
);
execlp
(
"/bin/sh"
,
"/bin/sh"
,
(
char
*
)
NULL
);
SYSERROR
(
"failed to exec shell"
);
SYSERROR
(
"failed to exec shell"
);
return
-
1
;
return
-
1
;
}
}
src/lxc/bdev/bdev.c
View file @
ef95dc01
...
@@ -721,7 +721,7 @@ int do_mkfs(const char *path, const char *fstype)
...
@@ -721,7 +721,7 @@ int do_mkfs(const char *path, const char *fstype)
// us about whether to proceed.
// us about whether to proceed.
if
(
null_stdfds
()
<
0
)
if
(
null_stdfds
()
<
0
)
exit
(
1
);
exit
(
1
);
execlp
(
"mkfs"
,
"mkfs"
,
"-t"
,
fstype
,
path
,
NULL
);
execlp
(
"mkfs"
,
"mkfs"
,
"-t"
,
fstype
,
path
,
(
char
*
)
NULL
);
exit
(
1
);
exit
(
1
);
}
}
...
...
src/lxc/bdev/lxclvm.c
View file @
ef95dc01
...
@@ -356,7 +356,7 @@ int lvm_destroy(struct bdev *orig)
...
@@ -356,7 +356,7 @@ int lvm_destroy(struct bdev *orig)
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"lvremove"
,
"lvremove"
,
"-f"
,
orig
->
src
,
NULL
);
execlp
(
"lvremove"
,
"lvremove"
,
"-f"
,
orig
->
src
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
return
wait_for_pid
(
pid
);
return
wait_for_pid
(
pid
);
...
...
src/lxc/bdev/lxcnbd.c
View file @
ef95dc01
...
@@ -228,7 +228,7 @@ static int do_attach_nbd(void *d)
...
@@ -228,7 +228,7 @@ static int do_attach_nbd(void *d)
if
(
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
)
==
-
1
)
if
(
sigprocmask
(
SIG_UNBLOCK
,
&
mask
,
NULL
)
==
-
1
)
WARN
(
"Warning: unblocking signals for nbd watcher"
);
WARN
(
"Warning: unblocking signals for nbd watcher"
);
execlp
(
"qemu-nbd"
,
"qemu-nbd"
,
"-c"
,
nbd
,
path
,
NULL
);
execlp
(
"qemu-nbd"
,
"qemu-nbd"
,
"-c"
,
nbd
,
path
,
(
char
*
)
NULL
);
SYSERROR
(
"Error executing qemu-nbd"
);
SYSERROR
(
"Error executing qemu-nbd"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -273,7 +273,7 @@ static void nbd_detach(const char *path)
...
@@ -273,7 +273,7 @@ static void nbd_detach(const char *path)
ERROR
(
"nbd disconnect returned an error"
);
ERROR
(
"nbd disconnect returned an error"
);
return
;
return
;
}
}
execlp
(
"qemu-nbd"
,
"qemu-nbd"
,
"-d"
,
path
,
NULL
);
execlp
(
"qemu-nbd"
,
"qemu-nbd"
,
"-d"
,
path
,
(
char
*
)
NULL
);
SYSERROR
(
"Error executing qemu-nbd"
);
SYSERROR
(
"Error executing qemu-nbd"
);
exit
(
1
);
exit
(
1
);
}
}
...
...
src/lxc/bdev/lxcrbd.c
View file @
ef95dc01
...
@@ -85,7 +85,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
...
@@ -85,7 +85,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"rbd"
,
"rbd"
,
"create"
,
"--pool"
,
rbdpool
,
rbdname
,
"--size"
,
sz
,
NULL
);
execlp
(
"rbd"
,
"rbd"
,
"create"
,
"--pool"
,
rbdpool
,
rbdname
,
"--size"
,
sz
,
(
char
*
)
NULL
);
exit
(
1
);
exit
(
1
);
}
}
if
(
wait_for_pid
(
pid
)
<
0
)
if
(
wait_for_pid
(
pid
)
<
0
)
...
@@ -94,7 +94,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
...
@@ -94,7 +94,7 @@ int rbd_create(struct bdev *bdev, const char *dest, const char *n,
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"rbd"
,
"rbd"
,
"map"
,
"--pool"
,
rbdpool
,
rbdname
,
NULL
);
execlp
(
"rbd"
,
"rbd"
,
"map"
,
"--pool"
,
rbdpool
,
rbdname
,
(
char
*
)
NULL
);
exit
(
1
);
exit
(
1
);
}
}
if
(
wait_for_pid
(
pid
)
<
0
)
if
(
wait_for_pid
(
pid
)
<
0
)
...
@@ -129,7 +129,7 @@ int rbd_destroy(struct bdev *orig)
...
@@ -129,7 +129,7 @@ int rbd_destroy(struct bdev *orig)
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"rbd"
,
"rbd"
,
"unmap"
,
orig
->
src
,
NULL
);
execlp
(
"rbd"
,
"rbd"
,
"unmap"
,
orig
->
src
,
(
char
*
)
NULL
);
exit
(
1
);
exit
(
1
);
}
}
if
(
wait_for_pid
(
pid
)
<
0
)
if
(
wait_for_pid
(
pid
)
<
0
)
...
@@ -141,7 +141,7 @@ int rbd_destroy(struct bdev *orig)
...
@@ -141,7 +141,7 @@ int rbd_destroy(struct bdev *orig)
if
(
!
pid
)
{
if
(
!
pid
)
{
rbdfullname
=
alloca
(
strlen
(
orig
->
src
)
-
8
);
rbdfullname
=
alloca
(
strlen
(
orig
->
src
)
-
8
);
strcpy
(
rbdfullname
,
&
orig
->
src
[
9
]
);
strcpy
(
rbdfullname
,
&
orig
->
src
[
9
]
);
execlp
(
"rbd"
,
"rbd"
,
"rm"
,
rbdfullname
,
NULL
);
execlp
(
"rbd"
,
"rbd"
,
"rm"
,
rbdfullname
,
(
char
*
)
NULL
);
exit
(
1
);
exit
(
1
);
}
}
return
wait_for_pid
(
pid
);
return
wait_for_pid
(
pid
);
...
...
src/lxc/bdev/lxczfs.c
View file @
ef95dc01
...
@@ -150,7 +150,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
...
@@ -150,7 +150,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
ret
=
snprintf
(
dev
,
MAXPATHLEN
,
"%s/%s"
,
zfsroot
,
nname
);
ret
=
snprintf
(
dev
,
MAXPATHLEN
,
"%s/%s"
,
zfsroot
,
nname
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
execlp
(
"zfs"
,
"zfs"
,
"create"
,
option
,
dev
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"create"
,
option
,
dev
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
return
wait_for_pid
(
pid
);
return
wait_for_pid
(
pid
);
...
@@ -170,7 +170,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
...
@@ -170,7 +170,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"zfs"
,
"zfs"
,
"destroy"
,
path1
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"destroy"
,
path1
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
// it probably doesn't exist so destroy probably will fail.
// it probably doesn't exist so destroy probably will fail.
...
@@ -180,7 +180,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
...
@@ -180,7 +180,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"zfs"
,
"zfs"
,
"snapshot"
,
path1
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"snapshot"
,
path1
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
wait_for_pid
(
pid
)
<
0
)
if
(
wait_for_pid
(
pid
)
<
0
)
...
@@ -190,7 +190,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
...
@@ -190,7 +190,7 @@ int zfs_clone(const char *opath, const char *npath, const char *oname,
if
((
pid
=
fork
())
<
0
)
if
((
pid
=
fork
())
<
0
)
return
-
1
;
return
-
1
;
if
(
!
pid
)
{
if
(
!
pid
)
{
execlp
(
"zfs"
,
"zfs"
,
"clone"
,
option
,
path1
,
path2
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"clone"
,
option
,
path1
,
path2
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
return
wait_for_pid
(
pid
);
return
wait_for_pid
(
pid
);
...
@@ -252,7 +252,7 @@ int zfs_destroy(struct bdev *orig)
...
@@ -252,7 +252,7 @@ int zfs_destroy(struct bdev *orig)
return
-
1
;
return
-
1
;
*
p
=
'\0'
;
*
p
=
'\0'
;
execlp
(
"zfs"
,
"zfs"
,
"destroy"
,
output
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"destroy"
,
output
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -291,6 +291,6 @@ int zfs_create(struct bdev *bdev, const char *dest, const char *n,
...
@@ -291,6 +291,6 @@ int zfs_create(struct bdev *bdev, const char *dest, const char *n,
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
execlp
(
"zfs"
,
"zfs"
,
"create"
,
option
,
dev
,
NULL
);
execlp
(
"zfs"
,
"zfs"
,
"create"
,
option
,
dev
,
(
char
*
)
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
src/lxc/network.c
View file @
ef95dc01
...
@@ -162,7 +162,7 @@ static char * is_wlan(const char *ifname)
...
@@ -162,7 +162,7 @@ static char * is_wlan(const char *ifname)
fseek
(
f
,
0
,
SEEK_SET
);
fseek
(
f
,
0
,
SEEK_SET
);
physname
=
malloc
(
physlen
+
1
);
physname
=
malloc
(
physlen
+
1
);
if
(
!
physname
)
{
if
(
!
physname
)
{
fclose
(
f
);
fclose
(
f
);
goto
bad
;
goto
bad
;
}
}
memset
(
physname
,
0
,
physlen
+
1
);
memset
(
physname
,
0
,
physlen
+
1
);
...
@@ -221,7 +221,7 @@ lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid, const char*
...
@@ -221,7 +221,7 @@ lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid, const char*
if
(
fpid
==
0
)
{
if
(
fpid
==
0
)
{
char
pidstr
[
30
];
char
pidstr
[
30
];
sprintf
(
pidstr
,
"%d"
,
pid
);
sprintf
(
pidstr
,
"%d"
,
pid
);
if
(
execlp
(
"iw"
,
"iw"
,
"phy"
,
physname
,
"set"
,
"netns"
,
pidstr
,
NULL
))
if
(
execlp
(
"iw"
,
"iw"
,
"phy"
,
physname
,
"set"
,
"netns"
,
pidstr
,
(
char
*
)
NULL
))
exit
(
1
);
exit
(
1
);
exit
(
0
);
// notreached
exit
(
0
);
// notreached
}
}
...
@@ -1056,13 +1056,13 @@ static int ip_addr_add(int family, int ifindex,
...
@@ -1056,13 +1056,13 @@ static int ip_addr_add(int family, int ifindex,
nlmsg
->
nlmsghdr
->
nlmsg_type
=
RTM_NEWADDR
;
nlmsg
->
nlmsghdr
->
nlmsg_type
=
RTM_NEWADDR
;
ifa
=
nlmsg_reserve
(
nlmsg
,
sizeof
(
struct
ifaddrmsg
));
ifa
=
nlmsg_reserve
(
nlmsg
,
sizeof
(
struct
ifaddrmsg
));
if
(
!
ifa
)
if
(
!
ifa
)
goto
out
;
goto
out
;
ifa
->
ifa_prefixlen
=
prefix
;
ifa
->
ifa_prefixlen
=
prefix
;
ifa
->
ifa_index
=
ifindex
;
ifa
->
ifa_index
=
ifindex
;
ifa
->
ifa_family
=
family
;
ifa
->
ifa_family
=
family
;
ifa
->
ifa_scope
=
0
;
ifa
->
ifa_scope
=
0
;
err
=
-
EINVAL
;
err
=
-
EINVAL
;
if
(
nla_put_buffer
(
nlmsg
,
IFA_LOCAL
,
addr
,
addrlen
))
if
(
nla_put_buffer
(
nlmsg
,
IFA_LOCAL
,
addr
,
addrlen
))
goto
out
;
goto
out
;
...
@@ -1339,23 +1339,23 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
...
@@ -1339,23 +1339,23 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
struct
rtmsg
*
rt
;
struct
rtmsg
*
rt
;
int
addrlen
;
int
addrlen
;
int
err
;
int
err
;
addrlen
=
family
==
AF_INET
?
sizeof
(
struct
in_addr
)
:
addrlen
=
family
==
AF_INET
?
sizeof
(
struct
in_addr
)
:
sizeof
(
struct
in6_addr
);
sizeof
(
struct
in6_addr
);
err
=
netlink_open
(
&
nlh
,
NETLINK_ROUTE
);
err
=
netlink_open
(
&
nlh
,
NETLINK_ROUTE
);
if
(
err
)
if
(
err
)
return
err
;
return
err
;
err
=
-
ENOMEM
;
err
=
-
ENOMEM
;
nlmsg
=
nlmsg_alloc
(
NLMSG_GOOD_SIZE
);
nlmsg
=
nlmsg_alloc
(
NLMSG_GOOD_SIZE
);
if
(
!
nlmsg
)
if
(
!
nlmsg
)
goto
out
;
goto
out
;
answer
=
nlmsg_alloc_reserve
(
NLMSG_GOOD_SIZE
);
answer
=
nlmsg_alloc_reserve
(
NLMSG_GOOD_SIZE
);
if
(
!
answer
)
if
(
!
answer
)
goto
out
;
goto
out
;
nlmsg
->
nlmsghdr
->
nlmsg_flags
=
nlmsg
->
nlmsghdr
->
nlmsg_flags
=
NLM_F_ACK
|
NLM_F_REQUEST
|
NLM_F_CREATE
|
NLM_F_EXCL
;
NLM_F_ACK
|
NLM_F_REQUEST
|
NLM_F_CREATE
|
NLM_F_EXCL
;
nlmsg
->
nlmsghdr
->
nlmsg_type
=
RTM_NEWROUTE
;
nlmsg
->
nlmsghdr
->
nlmsg_type
=
RTM_NEWROUTE
;
...
@@ -1369,7 +1369,7 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
...
@@ -1369,7 +1369,7 @@ static int ip_route_dest_add(int family, int ifindex, void *dest)
rt
->
rtm_protocol
=
RTPROT_BOOT
;
rt
->
rtm_protocol
=
RTPROT_BOOT
;
rt
->
rtm_type
=
RTN_UNICAST
;
rt
->
rtm_type
=
RTN_UNICAST
;
rt
->
rtm_dst_len
=
addrlen
*
8
;
rt
->
rtm_dst_len
=
addrlen
*
8
;
err
=
-
EINVAL
;
err
=
-
EINVAL
;
if
(
nla_put_buffer
(
nlmsg
,
RTA_DST
,
dest
,
addrlen
))
if
(
nla_put_buffer
(
nlmsg
,
RTA_DST
,
dest
,
addrlen
))
goto
out
;
goto
out
;
...
@@ -1414,7 +1414,7 @@ static void ovs_cleanup_nic(const char *lxcpath, const char *name, const char *b
...
@@ -1414,7 +1414,7 @@ static void ovs_cleanup_nic(const char *lxcpath, const char *name, const char *b
return
;
return
;
if
(
lxc_wait
(
name
,
"STOPPED"
,
-
1
,
lxcpath
)
<
0
)
if
(
lxc_wait
(
name
,
"STOPPED"
,
-
1
,
lxcpath
)
<
0
)
return
;
return
;
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"del-port"
,
bridge
,
nic
,
NULL
);
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"del-port"
,
bridge
,
nic
,
(
char
*
)
NULL
);
exit
(
1
);
/* not reached */
exit
(
1
);
/* not reached */
}
}
...
@@ -1445,7 +1445,7 @@ static int attach_to_ovs_bridge(const char *lxcpath, const char *name, const cha
...
@@ -1445,7 +1445,7 @@ static int attach_to_ovs_bridge(const char *lxcpath, const char *name, const cha
exit
(
0
);
exit
(
0
);
}
}
if
(
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"add-port"
,
bridge
,
nic
,
NULL
))
if
(
execlp
(
"ovs-vsctl"
,
"ovs-vsctl"
,
"add-port"
,
bridge
,
nic
,
(
char
*
)
NULL
))
exit
(
1
);
exit
(
1
);
// not reached
// not reached
exit
(
1
);
exit
(
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