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
6712de30
Unverified
Commit
6712de30
authored
Mar 27, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: make string calculations in get_network_config_ops() more obvious
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
6219606b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
confile.c
src/lxc/confile.c
+5
-5
No files found.
src/lxc/confile.c
View file @
6712de30
...
...
@@ -4708,7 +4708,7 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
char
*
idx_start
,
*
idx_end
;
/* check that this is a sensible network key */
if
(
!
strnequal
(
"lxc.net."
,
key
,
8
))
if
(
!
strnequal
(
"lxc.net."
,
key
,
STRLITERALLEN
(
"lxc.net."
)
))
return
log_error_errno
(
NULL
,
EINVAL
,
"Invalid network configuration key
\"
%s
\"
"
,
key
);
copy
=
strdup
(
key
);
...
...
@@ -4716,15 +4716,15 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
return
log_error_errno
(
NULL
,
ENOMEM
,
"Failed to duplicate string
\"
%s
\"
"
,
key
);
/* lxc.net.<n> */
if
(
!
isdigit
(
*
(
key
+
8
)))
if
(
!
isdigit
(
*
(
key
+
STRLITERALLEN
(
"lxc.net."
)
)))
return
log_error_errno
(
NULL
,
EINVAL
,
"Failed to detect digit in string
\"
%s
\"
"
,
key
+
8
);
/* beginning of index string */
idx_start
=
(
copy
+
7
);
idx_start
=
copy
+
(
STRLITERALLEN
(
"lxc.net."
)
-
1
);
*
idx_start
=
'\0'
;
/* end of index string */
idx_end
=
strchr
((
copy
+
8
),
'.'
);
idx_end
=
strchr
((
copy
+
STRLITERALLEN
(
"lxc.net."
)
),
'.'
);
if
(
idx_end
)
*
idx_end
=
'\0'
;
...
...
@@ -4754,7 +4754,7 @@ static struct lxc_config_t *get_network_config_ops(const char *key,
if
(
strlen
(
idx_end
+
1
)
==
0
)
return
log_error_errno
(
NULL
,
EINVAL
,
"No subkey in network configuration key
\"
%s
\"
"
,
key
);
memmove
(
copy
+
8
,
idx_end
+
1
,
strlen
(
idx_end
+
1
));
memmove
(
copy
+
STRLITERALLEN
(
"lxc.net."
)
,
idx_end
+
1
,
strlen
(
idx_end
+
1
));
copy
[
strlen
(
key
)
-
(
numstrlen
+
1
)]
=
'\0'
;
config
=
lxc_get_config
(
copy
);
...
...
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