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
64e82f8b
Unverified
Commit
64e82f8b
authored
Jun 20, 2018
by
Donghwa Jeong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secure coding: cgfsng: strncat, strlcpy
Signed-off-by:
Donghwa Jeong
<
dh48.jeong@samsung.com
>
parent
efed99a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
cgfsng.c
src/lxc/cgroups/cgfsng.c
+25
-13
No files found.
src/lxc/cgroups/cgfsng.c
View file @
64e82f8b
...
...
@@ -58,6 +58,10 @@
#include "storage/storage.h"
#include "utils.h"
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#endif
lxc_log_define
(
lxc_cgfsng
,
lxc
);
static
void
free_string_list
(
char
**
clist
)
...
...
@@ -1195,19 +1199,23 @@ static bool cg_unified_create_cgroup(struct hierarchy *h, char *cgname)
* some thinking.
*/
for
(
it
=
h
->
controllers
;
it
&&
*
it
;
it
++
)
{
full_len
+=
strlen
(
*
it
)
+
2
;
add_controllers
=
must_realloc
(
add_controllers
,
full_len
+
1
);
if
(
h
->
controllers
[
0
]
==
*
it
)
add_controllers
[
0
]
=
'\0'
;
strcat
(
add_controllers
,
"+"
);
strcat
(
add_controllers
,
*
it
);
if
((
it
+
1
)
&&
*
(
it
+
1
))
strcat
(
add_controllers
,
" "
);
full_len
+=
strlen
(
*
it
)
+
2
;
add_controllers
=
must_realloc
(
add_controllers
,
full_len
+
1
);
if
(
h
->
controllers
[
0
]
==
*
it
)
add_controllers
[
0
]
=
'\0'
;
strncat
(
add_controllers
,
"+"
,
1
);
strncat
(
add_controllers
,
*
it
,
strlen
(
*
it
));
if
((
it
+
1
)
&&
*
(
it
+
1
))
strncat
(
add_controllers
,
" "
,
1
);
}
parts
=
lxc_string_split
(
cgname
,
'/'
);
if
(
!
parts
)
goto
on_error
;
parts_len
=
lxc_array_len
((
void
**
)
parts
);
if
(
parts_len
>
0
)
parts_len
--
;
...
...
@@ -1301,9 +1309,10 @@ static inline bool cgfsng_create(struct cgroup_ops *ops,
ERROR
(
"Failed expanding cgroup name pattern"
);
return
false
;
}
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
container_cgroup
=
must_alloc
(
len
);
strcpy
(
container_cgroup
,
tmp
);
(
void
)
strlcpy
(
container_cgroup
,
tmp
,
len
);
free
(
tmp
);
offset
=
container_cgroup
+
len
-
5
;
...
...
@@ -1942,7 +1951,7 @@ static int __cg_unified_attach(const struct hierarchy *h, const char *name,
if
(
ret
<
0
&&
errno
!=
EEXIST
)
goto
on_error
;
str
cat
(
full_path
,
"/cgroup.procs"
);
str
ncat
(
full_path
,
"/cgroup.procs"
,
strlen
(
"/cgroup.procs"
)
);
ret
=
lxc_write_to_file
(
full_path
,
pidstr
,
len
,
false
,
0666
);
if
(
ret
==
0
)
goto
on_success
;
...
...
@@ -2022,7 +2031,8 @@ static int cgfsng_get(struct cgroup_ops *ops, const char *filename, char *value,
controller_len
=
strlen
(
filename
);
controller
=
alloca
(
controller_len
+
1
);
strcpy
(
controller
,
filename
);
(
void
)
strlcpy
(
controller
,
filename
,
controller_len
+
1
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
@@ -2059,7 +2069,8 @@ static int cgfsng_set(struct cgroup_ops *ops, const char *filename,
controller_len
=
strlen
(
filename
);
controller
=
alloca
(
controller_len
+
1
);
strcpy
(
controller
,
filename
);
(
void
)
strlcpy
(
controller
,
filename
,
controller_len
+
1
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
@@ -2176,7 +2187,8 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
len
=
strlen
(
filename
);
controller
=
alloca
(
len
+
1
);
strcpy
(
controller
,
filename
);
(
void
)
strlcpy
(
controller
,
filename
,
len
+
1
);
p
=
strchr
(
controller
,
'.'
);
if
(
p
)
*
p
=
'\0'
;
...
...
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