Merge pull request #10670 from yuwata/oss-fuzz-netdev-fixes
network: ignore multiple assignment of netdev kind
This commit is contained in:
commit
e1b2d44366
|
@ -97,7 +97,41 @@ static const char* const netdev_kind_table[_NETDEV_KIND_MAX] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind);
|
DEFINE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind);
|
||||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_netdev_kind, netdev_kind, NetDevKind, "Failed to parse netdev kind");
|
|
||||||
|
int config_parse_netdev_kind(
|
||||||
|
const char *unit,
|
||||||
|
const char *filename,
|
||||||
|
unsigned line,
|
||||||
|
const char *section,
|
||||||
|
unsigned section_line,
|
||||||
|
const char *lvalue,
|
||||||
|
int ltype,
|
||||||
|
const char *rvalue,
|
||||||
|
void *data,
|
||||||
|
void *userdata) {
|
||||||
|
|
||||||
|
NetDevKind k, *kind = data;
|
||||||
|
|
||||||
|
assert(rvalue);
|
||||||
|
assert(data);
|
||||||
|
|
||||||
|
k = netdev_kind_from_string(rvalue);
|
||||||
|
if (k < 0) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*kind != _NETDEV_KIND_INVALID && *kind != k) {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||||
|
"Specified netdev kind is different from the previous value '%s', ignoring assignment: %s",
|
||||||
|
netdev_kind_to_string(*kind), rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*kind = k;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void netdev_callbacks_clear(NetDev *netdev) {
|
static void netdev_callbacks_clear(NetDev *netdev) {
|
||||||
netdev_join_callback *callback;
|
netdev_join_callback *callback;
|
||||||
|
|
|
@ -46,17 +46,14 @@ struct Wireguard {
|
||||||
NetDev meta;
|
NetDev meta;
|
||||||
unsigned last_peer_section;
|
unsigned last_peer_section;
|
||||||
|
|
||||||
char interface[IFNAMSIZ];
|
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
|
||||||
uint8_t public_key[WG_KEY_LEN];
|
|
||||||
uint8_t private_key[WG_KEY_LEN];
|
uint8_t private_key[WG_KEY_LEN];
|
||||||
uint32_t fwmark;
|
uint32_t fwmark;
|
||||||
|
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
|
||||||
LIST_HEAD(WireguardPeer, peers);
|
LIST_HEAD(WireguardPeer, peers);
|
||||||
size_t allocation_size;
|
|
||||||
|
|
||||||
LIST_HEAD(WireguardEndpoint, unresolved_endpoints);
|
LIST_HEAD(WireguardEndpoint, unresolved_endpoints);
|
||||||
LIST_HEAD(WireguardEndpoint, failed_endpoints);
|
LIST_HEAD(WireguardEndpoint, failed_endpoints);
|
||||||
|
|
BIN
test/fuzz/fuzz-netdev-parser/oss-fuzz-11279
Normal file
BIN
test/fuzz/fuzz-netdev-parser/oss-fuzz-11279
Normal file
Binary file not shown.
BIN
test/fuzz/fuzz-netdev-parser/oss-fuzz-11280
Normal file
BIN
test/fuzz/fuzz-netdev-parser/oss-fuzz-11280
Normal file
Binary file not shown.
Loading…
Reference in a new issue