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
8c70a408
Unverified
Commit
8c70a408
authored
Mar 26, 2021
by
Stéphane Graber
Committed by
GitHub
Mar 26, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3736 from brauner/2021-03-26/fixes_3
oss-fuzz: fixes
parents
6583a650
06fdc710
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
34 deletions
+35
-34
confile.c
src/lxc/confile.c
+5
-11
confile_utils.c
src/lxc/confile_utils.c
+15
-14
log.c
src/lxc/log.c
+0
-3
string_utils.c
src/lxc/string_utils.c
+15
-6
No files found.
src/lxc/confile.c
View file @
8c70a408
...
@@ -626,8 +626,8 @@ static int set_config_net_ipvlan_isolation(const char *key, const char *value,
...
@@ -626,8 +626,8 @@ static int set_config_net_ipvlan_isolation(const char *key, const char *value,
static
int
set_config_net_hwaddr
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_net_hwaddr
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
__do_free
char
*
new_value
=
NULL
;
struct
lxc_netdev
*
netdev
=
data
;
struct
lxc_netdev
*
netdev
=
data
;
char
*
new_value
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
clr_config_net_hwaddr
(
key
,
lxc_conf
,
data
);
return
clr_config_net_hwaddr
(
key
,
lxc_conf
,
data
);
...
@@ -641,13 +641,10 @@ static int set_config_net_hwaddr(const char *key, const char *value,
...
@@ -641,13 +641,10 @@ static int set_config_net_hwaddr(const char *key, const char *value,
rand_complete_hwaddr
(
new_value
);
rand_complete_hwaddr
(
new_value
);
if
(
lxc_config_value_empty
(
new_value
))
{
if
(
lxc_config_value_empty
(
new_value
))
free
(
new_value
);
free_disarm
(
netdev
->
hwaddr
);
netdev
->
hwaddr
=
NULL
;
else
return
0
;
netdev
->
hwaddr
=
move_ptr
(
new_value
);
}
netdev
->
hwaddr
=
new_value
;
return
0
;
return
0
;
}
}
...
@@ -1600,9 +1597,6 @@ static int set_config_log_file(const char *key, const char *value,
...
@@ -1600,9 +1597,6 @@ static int set_config_log_file(const char *key, const char *value,
return
0
;
return
0
;
}
}
if
(
!
abspath
(
value
))
return
ret_errno
(
EINVAL
);
/*
/*
* Store these values in the lxc_conf, and then try to set for actual
* Store these values in the lxc_conf, and then try to set for actual
* current logging.
* current logging.
...
...
src/lxc/confile_utils.c
View file @
8c70a408
...
@@ -169,7 +169,6 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
...
@@ -169,7 +169,6 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
if
(
!
netdev
)
if
(
!
netdev
)
return
ret_set_errno
(
NULL
,
ENOMEM
);
return
ret_set_errno
(
NULL
,
ENOMEM
);
memset
(
netdev
,
0
,
sizeof
(
*
netdev
));
lxc_list_init
(
&
netdev
->
ipv4
);
lxc_list_init
(
&
netdev
->
ipv4
);
lxc_list_init
(
&
netdev
->
ipv6
);
lxc_list_init
(
&
netdev
->
ipv6
);
...
@@ -177,11 +176,9 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
...
@@ -177,11 +176,9 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
netdev
->
idx
=
idx
;
netdev
->
idx
=
idx
;
/* prepare new list */
/* prepare new list */
newlist
=
zalloc
(
sizeof
(
*
newlist
)
);
newlist
=
lxc_list_new
(
);
if
(
!
newlist
)
if
(
!
newlist
)
return
ret_set_errno
(
NULL
,
ENOMEM
);
return
ret_set_errno
(
NULL
,
ENOMEM
);
lxc_list_init
(
newlist
);
newlist
->
elem
=
netdev
;
newlist
->
elem
=
netdev
;
if
(
tail
)
if
(
tail
)
...
@@ -199,25 +196,27 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
...
@@ -199,25 +196,27 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
struct
lxc_netdev
*
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
struct
lxc_netdev
*
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
,
bool
allocate
)
unsigned
int
idx
,
bool
allocate
)
{
{
struct
lxc_netdev
*
netdev
=
NULL
;
struct
lxc_list
*
networks
=
&
conf
->
network
;
struct
lxc_list
*
networks
=
&
conf
->
network
;
struct
lxc_list
*
insert
=
networks
;
struct
lxc_list
*
insert
=
networks
;
/* lookup network */
/* lookup network */
if
(
!
lxc_list_empty
(
networks
))
{
if
(
!
lxc_list_empty
(
networks
))
{
lxc_list_for_each
(
insert
,
networks
)
{
lxc_list_for_each
(
insert
,
networks
)
{
netdev
=
insert
->
elem
;
struct
lxc_netdev
*
netdev
=
insert
->
elem
;
/* found network device */
if
(
netdev
->
idx
==
idx
)
if
(
netdev
->
idx
==
idx
)
return
netdev
;
return
netdev
;
else
if
(
netdev
->
idx
>
idx
)
if
(
netdev
->
idx
>
idx
)
break
;
break
;
}
}
}
}
if
(
!
allocate
)
if
(
allocate
)
return
ret_set_errno
(
NULL
,
EINVAL
);
return
lxc_network_add
(
insert
,
idx
,
true
);
return
lxc_network_add
(
insert
,
idx
,
true
)
;
return
NULL
;
}
}
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
)
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
)
...
@@ -452,19 +451,21 @@ static void lxc_free_netdev(struct lxc_netdev *netdev)
...
@@ -452,19 +451,21 @@ static void lxc_free_netdev(struct lxc_netdev *netdev)
free
(
netdev
);
free
(
netdev
);
}
}
define_cleanup_function
(
struct
lxc_netdev
*
,
lxc_free_netdev
);
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
{
{
call_cleaner
(
lxc_free_netdev
)
struct
lxc_netdev
*
netdev
=
NULL
;
struct
lxc_list
*
cur
,
*
next
;
struct
lxc_list
*
cur
,
*
next
;
if
(
lxc_list_empty
(
&
conf
->
network
))
return
false
;
lxc_list_for_each_safe
(
cur
,
&
conf
->
network
,
next
)
{
lxc_list_for_each_safe
(
cur
,
&
conf
->
network
,
next
)
{
netdev
=
cur
->
elem
;
struct
lxc_netdev
*
netdev
=
cur
->
elem
;
if
(
netdev
->
idx
!=
idx
)
if
(
netdev
->
idx
!=
idx
)
continue
;
continue
;
lxc_list_del
(
cur
);
lxc_list_del
(
cur
);
lxc_free_netdev
(
netdev
);
return
true
;
return
true
;
}
}
...
...
src/lxc/log.c
View file @
8c70a408
...
@@ -492,9 +492,6 @@ static int build_dir(const char *name)
...
@@ -492,9 +492,6 @@ static int build_dir(const char *name)
if
(
is_empty_string
(
name
))
if
(
is_empty_string
(
name
))
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
if
(
!
abspath
(
name
))
return
ret_errno
(
EINVAL
);
/* Make copy of the string since we'll be modifying it. */
/* Make copy of the string since we'll be modifying it. */
n
=
strdup
(
name
);
n
=
strdup
(
name
);
if
(
!
n
)
if
(
!
n
)
...
...
src/lxc/string_utils.c
View file @
8c70a408
...
@@ -906,7 +906,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
...
@@ -906,7 +906,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
suffix
[
3
]
=
{
0
};
char
suffix
[
3
]
=
{
0
};
if
(
!
s
||
strequal
(
s
,
""
))
if
(
is_empty_string
(
s
))
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
...
@@ -920,17 +920,26 @@ int parse_byte_size_string(const char *s, int64_t *converted)
...
@@ -920,17 +920,26 @@ int parse_byte_size_string(const char *s, int64_t *converted)
else
else
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
if
(
suffix_len
>
0
&&
(
end
-
2
)
==
dup
&&
!
isdigit
(
*
(
end
-
2
)))
if
(
suffix_len
>
0
)
{
return
ret_errno
(
EINVAL
);
if
((
end
-
1
)
==
dup
)
return
ret_errno
(
EINVAL
);
if
(
suffix_len
>
0
&&
isalpha
(
*
(
end
-
2
)))
if
((
end
-
2
)
==
dup
)
{
suffix_len
++
;
if
(
isalpha
(
*
(
end
-
2
)))
return
ret_errno
(
EINVAL
);
/* 1B */
}
else
{
if
(
isalpha
(
*
(
end
-
2
)))
/* 12MB */
suffix_len
++
;
/* 12B */
}
if
(
suffix_len
>
0
)
{
memcpy
(
suffix
,
end
-
suffix_len
,
suffix_len
);
memcpy
(
suffix
,
end
-
suffix_len
,
suffix_len
);
*
(
suffix
+
suffix_len
)
=
'\0'
;
*
(
suffix
+
suffix_len
)
=
'\0'
;
*
(
end
-
suffix_len
)
=
'\0'
;
*
(
end
-
suffix_len
)
=
'\0'
;
}
}
dup
[
lxc_char_right_gc
(
dup
,
strlen
(
dup
))]
=
'\0'
;
dup
[
lxc_char_right_gc
(
dup
,
strlen
(
dup
))]
=
'\0'
;
ret
=
lxc_safe_long_long
(
dup
,
&
conv
);
ret
=
lxc_safe_long_long
(
dup
,
&
conv
);
...
...
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