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
fe38f0b1
Unverified
Commit
fe38f0b1
authored
Apr 06, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: enforce maximum subkey length
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b33f435d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
confile.c
src/lxc/confile.c
+18
-4
No files found.
src/lxc/confile.c
View file @
fe38f0b1
...
...
@@ -281,12 +281,22 @@ struct lxc_config_t *lxc_get_config_exact(const char *key)
return
NULL
;
}
static
inline
bool
match_config_item
(
const
struct
lxc_config_t
*
entry
,
const
char
*
key
)
/* Assume a reasonable subkey size limit. */
#define LXC_SUBKEY_LEN_MAX 256
static
inline
int
match_config_item
(
const
struct
lxc_config_t
*
entry
,
const
char
*
key
)
{
size_t
len
;
if
(
entry
->
strict
)
return
strequal
(
entry
->
name
,
key
);
return
strnequal
(
entry
->
name
,
key
,
strlen
(
entry
->
name
));
/* There should be no subkey longer than this. */
len
=
strnlen
(
entry
->
name
,
LXC_SUBKEY_LEN_MAX
);
if
(
len
==
LXC_SUBKEY_LEN_MAX
)
return
error_ret
(
-
E2BIG
,
"Excessive subkey length"
);
return
strnequal
(
entry
->
name
,
key
,
len
);
}
struct
lxc_config_t
*
lxc_get_config
(
const
char
*
key
)
...
...
@@ -294,8 +304,12 @@ struct lxc_config_t *lxc_get_config(const char *key)
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
config_jump_table
);
i
++
)
{
struct
lxc_config_t
*
cur
=
&
config_jump_table
[
i
];
if
(
!
match_config_item
(
cur
,
key
))
switch
(
match_config_item
(
cur
,
key
))
{
case
0
:
continue
;
case
-
E2BIG
:
return
NULL
;
}
return
cur
;
}
...
...
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