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
f36346a8
Commit
f36346a8
authored
Oct 29, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: use lxc_safe_{u}int()
Signed-off-by:
Christian Brauner
<
christian.brauner@canonical.com
>
parent
6b9550e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
conf.c
src/lxc/conf.c
+21
-8
No files found.
src/lxc/conf.c
View file @
f36346a8
...
@@ -2504,7 +2504,8 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -2504,7 +2504,8 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
{
{
char
veth1buf
[
IFNAMSIZ
],
*
veth1
;
char
veth1buf
[
IFNAMSIZ
],
*
veth1
;
char
veth2buf
[
IFNAMSIZ
],
*
veth2
;
char
veth2buf
[
IFNAMSIZ
],
*
veth2
;
int
bridge_index
,
err
,
mtu
=
0
;
int
bridge_index
,
err
;
unsigned
int
mtu
=
0
;
if
(
netdev
->
priv
.
veth_attr
.
pair
)
{
if
(
netdev
->
priv
.
veth_attr
.
pair
)
{
veth1
=
netdev
->
priv
.
veth_attr
.
pair
;
veth1
=
netdev
->
priv
.
veth_attr
.
pair
;
...
@@ -2556,8 +2557,10 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -2556,8 +2557,10 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
}
}
if
(
netdev
->
mtu
)
{
if
(
netdev
->
mtu
)
{
mtu
=
atoi
(
netdev
->
mtu
);
if
(
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
)
<
0
)
INFO
(
"Retrieved mtu %d"
,
mtu
);
WARN
(
"Failed to parse mtu from."
);
else
INFO
(
"Retrieved mtu %d"
,
mtu
);
}
else
if
(
netdev
->
link
)
{
}
else
if
(
netdev
->
link
)
{
bridge_index
=
if_nametoindex
(
netdev
->
link
);
bridge_index
=
if_nametoindex
(
netdev
->
link
);
if
(
bridge_index
)
{
if
(
bridge_index
)
{
...
@@ -2706,6 +2709,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -2706,6 +2709,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
char
peer
[
IFNAMSIZ
];
char
peer
[
IFNAMSIZ
];
int
err
;
int
err
;
static
uint16_t
vlan_cntr
=
0
;
static
uint16_t
vlan_cntr
=
0
;
unsigned
int
mtu
=
0
;
if
(
!
netdev
->
link
)
{
if
(
!
netdev
->
link
)
{
ERROR
(
"no link specified for vlan netdev"
);
ERROR
(
"no link specified for vlan netdev"
);
...
@@ -2735,7 +2739,12 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -2735,7 +2739,12 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
DEBUG
(
"instantiated vlan '%s', ifindex is '%d'"
,
" vlan1000"
,
DEBUG
(
"instantiated vlan '%s', ifindex is '%d'"
,
" vlan1000"
,
netdev
->
ifindex
);
netdev
->
ifindex
);
if
(
netdev
->
mtu
)
{
if
(
netdev
->
mtu
)
{
err
=
lxc_netdev_set_mtu
(
peer
,
atoi
(
netdev
->
mtu
));
if
(
lxc_safe_uint
(
netdev
->
mtu
,
&
mtu
)
<
0
)
{
ERROR
(
"Failed to retrieve mtu from: '%d'/'%s'."
,
netdev
->
ifindex
,
netdev
->
name
);
return
-
1
;
}
err
=
lxc_netdev_set_mtu
(
peer
,
mtu
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"failed to set mtu '%s' for %s : %s"
,
ERROR
(
"failed to set mtu '%s' for %s : %s"
,
netdev
->
mtu
,
peer
,
strerror
(
-
err
));
netdev
->
mtu
,
peer
,
strerror
(
-
err
));
...
@@ -4449,8 +4458,10 @@ void suggest_default_idmap(void)
...
@@ -4449,8 +4458,10 @@ void suggest_default_idmap(void)
p2
++
;
p2
++
;
if
(
!*
p2
)
if
(
!*
p2
)
continue
;
continue
;
uid
=
atoi
(
p
);
if
(
lxc_safe_uint
(
p
,
&
uid
)
<
0
)
urange
=
atoi
(
p2
);
WARN
(
"Could not parse UID."
);
if
(
lxc_safe_uint
(
p2
,
&
urange
)
<
0
)
WARN
(
"Could not parse UID range."
);
}
}
fclose
(
f
);
fclose
(
f
);
...
@@ -4478,8 +4489,10 @@ void suggest_default_idmap(void)
...
@@ -4478,8 +4489,10 @@ void suggest_default_idmap(void)
p2
++
;
p2
++
;
if
(
!*
p2
)
if
(
!*
p2
)
continue
;
continue
;
gid
=
atoi
(
p
);
if
(
lxc_safe_uint
(
p
,
&
gid
)
<
0
)
grange
=
atoi
(
p2
);
WARN
(
"Could not parse GID."
);
if
(
lxc_safe_uint
(
p2
,
&
grange
)
<
0
)
WARN
(
"Could not parse GID range."
);
}
}
fclose
(
f
);
fclose
(
f
);
...
...
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