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
c9651be4
Unverified
Commit
c9651be4
authored
Jun 18, 2018
by
Donghwa Jeong
Committed by
Christian Brauner
Jun 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secure coding: network: strcpy => strlcpy
Signed-off-by:
Donghwa Jeong
<
dh48.jeong@samsung.com
>
parent
604f3764
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
network.c
src/lxc/network.c
+10
-7
No files found.
src/lxc/network.c
100755 → 100644
View file @
c9651be4
...
...
@@ -1992,7 +1992,7 @@ char *lxc_mkifname(char *template)
/* Generate random names until we find one that doesn't exist. */
while
(
true
)
{
name
[
0
]
=
'\0'
;
strcpy
(
name
,
template
);
(
void
)
strlcpy
(
name
,
template
,
IFNAMSIZ
);
exists
=
false
;
for
(
i
=
0
;
i
<
strlen
(
name
);
i
++
)
{
...
...
@@ -2017,7 +2017,9 @@ char *lxc_mkifname(char *template)
}
freeifaddrs
(
ifaddr
);
return
strcpy
(
template
,
name
);
(
void
)
strlcpy
(
template
,
name
,
strlen
(
template
)
+
1
);
return
template
;
}
int
setup_private_host_hw_addr
(
char
*
veth1
)
...
...
@@ -2108,6 +2110,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
char
*
token
,
*
saveptr
=
NULL
;
char
netdev_link
[
IFNAMSIZ
];
char
buffer
[
MAXPATHLEN
]
=
{
0
};
size_t
retlen
;
if
(
netdev
->
type
!=
LXC_NET_VETH
)
{
ERROR
(
"Network type %d not support for unprivileged use"
,
netdev
->
type
);
...
...
@@ -2224,12 +2227,12 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
return
-
1
;
}
if
(
strlen
(
token
)
>=
IFNAMSIZ
)
{
retlen
=
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
token
,
IFNAMSIZ
);
if
(
retlen
>=
IFNAMSIZ
)
{
ERROR
(
"Host side veth device name returned by lxc-user-nic is "
"too long"
);
return
-
E2BIG
;
}
strcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
token
);
/* netdev->priv.veth_attr.ifindex */
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
...
...
@@ -2880,9 +2883,9 @@ static int lxc_setup_netdev_in_child_namespaces(struct lxc_netdev *netdev)
*/
if
(
netdev
->
name
[
0
]
==
'\0'
)
{
if
(
netdev
->
type
==
LXC_NET_PHYS
)
strcpy
(
netdev
->
name
,
netdev
->
link
);
(
void
)
strlcpy
(
netdev
->
name
,
netdev
->
link
,
IFNAMSIZ
);
else
strcpy
(
netdev
->
name
,
"eth%d"
);
(
void
)
strlcpy
(
netdev
->
name
,
"eth%d"
,
IFNAMSIZ
);
}
/* rename the interface name */
...
...
@@ -2908,7 +2911,7 @@ static int lxc_setup_netdev_in_child_namespaces(struct lxc_netdev *netdev)
* name of the network device in the child's network namespace. We will
* later on send this information back to the parent.
*/
strcpy
(
netdev
->
name
,
current_ifname
);
(
void
)
strlcpy
(
netdev
->
name
,
current_ifname
,
IFNAMSIZ
);
/* set a mac address */
if
(
netdev
->
hwaddr
)
{
...
...
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