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
4446e0fa
Unverified
Commit
4446e0fa
authored
Mar 30, 2020
by
Christian Brauner
Committed by
GitHub
Mar 30, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3339 from Blub/cmd-get-cgroup-string-termination
verify cgroup controller name
parents
6821739c
e6bc68d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
commands.c
src/lxc/commands.c
+35
-2
No files found.
src/lxc/commands.c
View file @
4446e0fa
...
...
@@ -325,6 +325,34 @@ int lxc_try_cmd(const char *name, const char *lxcpath)
return
0
;
}
/*
* Validate that the input is a proper string parameter. If not,
* send an EINVAL response and return -1.
*
* Precondition: there is non-zero-length data available.
*/
static
int
validate_string_request
(
int
fd
,
const
struct
lxc_cmd_req
*
req
)
{
int
ret
;
size_t
maxlen
=
req
->
datalen
-
1
;
const
char
*
data
=
req
->
data
;
if
(
data
[
maxlen
]
==
0
&&
strnlen
(
data
,
maxlen
)
==
maxlen
)
return
0
;
struct
lxc_cmd_rsp
rsp
=
{
.
ret
=
-
EINVAL
,
.
datalen
=
0
,
.
data
=
NULL
,
};
ret
=
lxc_cmd_rsp_send
(
fd
,
&
rsp
);
if
(
ret
<
0
)
return
LXC_CMD_REAP_CLIENT_FD
;
return
-
1
;
}
/* Implementations of the commands and their callbacks */
/*
...
...
@@ -506,10 +534,15 @@ static int lxc_cmd_get_cgroup_callback(int fd, struct lxc_cmd_req *req,
struct
lxc_cmd_rsp
rsp
;
struct
cgroup_ops
*
cgroup_ops
=
handler
->
cgroup_ops
;
if
(
req
->
datalen
>
0
)
if
(
req
->
datalen
>
0
)
{
ret
=
validate_string_request
(
fd
,
req
);
if
(
ret
!=
0
)
return
ret
;
path
=
cgroup_ops
->
get_cgroup
(
cgroup_ops
,
req
->
data
);
else
}
else
{
path
=
cgroup_ops
->
get_cgroup
(
cgroup_ops
,
NULL
);
}
if
(
!
path
)
return
-
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