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
6dcd23e2
Unverified
Commit
6dcd23e2
authored
Mar 31, 2021
by
Stéphane Graber
Committed by
GitHub
Mar 31, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3758 from brauner/2021-03-31/fixes
confile: cap to last bit in set_config_net_ipv4_address()
parents
ea35e2cc
36513635
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
confile.c
src/lxc/confile.c
+10
-10
macro.h
src/lxc/macro.h
+4
-0
No files found.
src/lxc/confile.c
View file @
6dcd23e2
...
...
@@ -781,22 +781,22 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
}
/* No prefix specified, determine it from the network class. */
if
(
prefix
)
{
ret
=
0
;
if
(
prefix
)
ret
=
lxc_safe_uint
(
prefix
,
&
inetdev
->
prefix
);
if
(
ret
<
0
)
return
ret
;
}
else
{
else
inetdev
->
prefix
=
config_ip_prefix
(
&
inetdev
->
addr
);
}
if
(
inetdev
->
prefix
>
32
)
if
(
ret
||
inetdev
->
prefix
>
32
)
return
ret_errno
(
EINVAL
);
/* If no broadcast address, let compute one from the
* prefix and address.
*/
/* If no broadcast address, compute one from the prefix and address. */
if
(
!
bcast
)
{
unsigned
int
shift
=
LAST_BIT_PER_TYPE
(
inetdev
->
prefix
);
inetdev
->
bcast
.
s_addr
=
inetdev
->
addr
.
s_addr
;
inetdev
->
bcast
.
s_addr
|=
htonl
(
INADDR_BROADCAST
>>
inetdev
->
prefix
);
if
(
inetdev
->
prefix
<
shift
)
shift
=
inetdev
->
prefix
;
inetdev
->
bcast
.
s_addr
|=
htonl
(
INADDR_BROADCAST
>>
shift
);
}
list
->
elem
=
inetdev
;
...
...
src/lxc/macro.h
View file @
6dcd23e2
...
...
@@ -737,4 +737,8 @@ enum {
#define __aligned_u64 __u64 __attribute__((aligned(8)))
#endif
#define BITS_PER_BYTE 8
#define BITS_PER_TYPE(type) (sizeof(type) * 8)
#define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1)
#endif
/* __LXC_MACRO_H */
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