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
604f3764
Unverified
Commit
604f3764
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: strcpy => strlcpy
Signed-off-by:
Donghwa Jeong
<
dh48.jeong@samsung.com
>
parent
e9674af4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
criu.c
src/lxc/criu.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+7
-3
start.c
src/lxc/start.c
+3
-1
btrfs.c
src/lxc/storage/btrfs.c
+8
-5
No files found.
src/lxc/criu.c
View file @
604f3764
...
@@ -923,7 +923,7 @@ static bool restore_net_info(struct lxc_container *c)
...
@@ -923,7 +923,7 @@ static bool restore_net_info(struct lxc_container *c)
if
(
!
lxc_mkifname
(
template
))
if
(
!
lxc_mkifname
(
template
))
goto
out_unlock
;
goto
out_unlock
;
strcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
template
);
(
void
)
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
template
,
IFNAMSIZ
);
}
}
}
}
...
...
src/lxc/lxccontainer.c
View file @
604f3764
...
@@ -1192,7 +1192,8 @@ static int do_create_container_dir(const char *path, struct lxc_conf *conf)
...
@@ -1192,7 +1192,8 @@ static int do_create_container_dir(const char *path, struct lxc_conf *conf)
len
=
strlen
(
path
);
len
=
strlen
(
path
);
p
=
alloca
(
len
+
1
);
p
=
alloca
(
len
+
1
);
strcpy
(
p
,
path
);
(
void
)
strlcpy
(
p
,
path
,
len
+
1
);
if
(
!
lxc_list_empty
(
&
conf
->
id_map
))
{
if
(
!
lxc_list_empty
(
&
conf
->
id_map
))
{
ret
=
chown_mapped_root
(
p
,
conf
);
ret
=
chown_mapped_root
(
p
,
conf
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -4777,6 +4778,7 @@ out:
...
@@ -4777,6 +4778,7 @@ out:
struct
lxc_container
*
lxc_container_new
(
const
char
*
name
,
const
char
*
configpath
)
struct
lxc_container
*
lxc_container_new
(
const
char
*
name
,
const
char
*
configpath
)
{
{
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
size_t
len
;
if
(
!
name
)
if
(
!
name
)
return
NULL
;
return
NULL
;
...
@@ -4799,12 +4801,14 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
...
@@ -4799,12 +4801,14 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath
}
}
remove_trailing_slashes
(
c
->
config_path
);
remove_trailing_slashes
(
c
->
config_path
);
c
->
name
=
malloc
(
strlen
(
name
)
+
1
);
len
=
strlen
(
name
);
c
->
name
=
malloc
(
len
+
1
);
if
(
!
c
->
name
)
{
if
(
!
c
->
name
)
{
fprintf
(
stderr
,
"Failed to allocate memory for %s
\n
"
,
name
);
fprintf
(
stderr
,
"Failed to allocate memory for %s
\n
"
,
name
);
goto
err
;
goto
err
;
}
}
strcpy
(
c
->
name
,
name
);
(
void
)
strlcpy
(
c
->
name
,
name
,
len
+
1
);
c
->
numthreads
=
1
;
c
->
numthreads
=
1
;
c
->
slock
=
lxc_newlock
(
c
->
config_path
,
name
);
c
->
slock
=
lxc_newlock
(
c
->
config_path
,
name
);
...
...
src/lxc/start.c
View file @
604f3764
...
@@ -110,9 +110,11 @@ static void print_top_failing_dir(const char *path)
...
@@ -110,9 +110,11 @@ static void print_top_failing_dir(const char *path)
len
=
strlen
(
path
);
len
=
strlen
(
path
);
copy
=
alloca
(
len
+
1
);
copy
=
alloca
(
len
+
1
);
strcpy
(
copy
,
path
);
(
void
)
strlcpy
(
copy
,
path
,
len
+
1
);
p
=
copy
;
p
=
copy
;
e
=
copy
+
len
;
e
=
copy
+
len
;
while
(
p
<
e
)
{
while
(
p
<
e
)
{
while
(
p
<
e
&&
*
p
==
'/'
)
while
(
p
<
e
&&
*
p
==
'/'
)
p
++
;
p
++
;
...
...
src/lxc/storage/btrfs.c
View file @
604f3764
...
@@ -88,8 +88,8 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
...
@@ -88,8 +88,8 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
retpath
=
malloc
(
len
);
retpath
=
malloc
(
len
);
if
(
!
retpath
)
if
(
!
retpath
)
return
NULL
;
return
NULL
;
strcpy
(
retpath
,
args
.
name
);
(
void
)
strlcpy
(
retpath
,
args
.
name
,
len
);
str
cat
(
retpath
,
"/"
);
str
ncat
(
retpath
,
"/"
,
1
);
strncat
(
retpath
,
name
,
name_len
);
strncat
(
retpath
,
name
,
name_len
);
}
else
{
}
else
{
/* we're at the root of ref_tree */
/* we're at the root of ref_tree */
...
@@ -602,17 +602,20 @@ static bool update_tree_node(struct mytree_node *n, u64 id, u64 parent,
...
@@ -602,17 +602,20 @@ static bool update_tree_node(struct mytree_node *n, u64 id, u64 parent,
if
(
!
n
->
name
)
if
(
!
n
->
name
)
return
false
;
return
false
;
strcpy
(
n
->
name
,
name
);
(
void
)
strlcpy
(
n
->
name
,
name
,
name_len
+
1
);
}
}
if
(
dirname
)
{
if
(
dirname
)
{
n
->
dirname
=
malloc
(
strlen
(
dirname
)
+
1
);
size_t
len
;
len
=
strlen
(
dirname
);
n
->
dirname
=
malloc
(
len
+
1
);
if
(
!
n
->
dirname
)
{
if
(
!
n
->
dirname
)
{
free
(
n
->
name
);
free
(
n
->
name
);
return
false
;
return
false
;
}
}
strcpy
(
n
->
dirname
,
dirname
);
(
void
)
strlcpy
(
n
->
dirname
,
dirname
,
len
+
1
);
}
}
return
true
;
return
true
;
}
}
...
...
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