network: fix use-of-uninitialized-value or null dereference
This fixes a bug introduced by 6ef5c881dd
.
Fixes oss-fuzz#14157 and oss-fuzz#14158.
This commit is contained in:
parent
55a37d7117
commit
86a3d44de5
|
@ -498,24 +498,18 @@ static int wireguard_decode_key_and_warn(
|
||||||
(void) warn_file_is_world_accessible(filename, NULL, unit, line);
|
(void) warn_file_is_world_accessible(filename, NULL, unit, line);
|
||||||
|
|
||||||
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
|
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
return log_syntax(unit, LOG_ERR, filename, line, r,
|
||||||
"Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue);
|
"Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue);
|
||||||
goto finalize;
|
|
||||||
}
|
|
||||||
if (len != WG_KEY_LEN) {
|
if (len != WG_KEY_LEN) {
|
||||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
explicit_bzero_safe(key, len);
|
||||||
|
return log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||||
"Wireguard key provided by %s= has invalid length (%zu bytes), ignoring assignment.",
|
"Wireguard key provided by %s= has invalid length (%zu bytes), ignoring assignment.",
|
||||||
lvalue, len);
|
lvalue, len);
|
||||||
goto finalize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ret, key, WG_KEY_LEN);
|
memcpy(ret, key, WG_KEY_LEN);
|
||||||
r = 0;
|
return 0;
|
||||||
|
|
||||||
finalize:
|
|
||||||
explicit_bzero_safe(key, len);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_wireguard_private_key(
|
int config_parse_wireguard_private_key(
|
||||||
|
|
5
test/fuzz/fuzz-netdev-parser/oss-fuzz-14157
Normal file
5
test/fuzz/fuzz-netdev-parser/oss-fuzz-14157
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[NetDev]
|
||||||
|
Name=w
|
||||||
|
Kind=wireguard
|
||||||
|
[WireGuardPeer]
|
||||||
|
PublicKey=e
|
5
test/fuzz/fuzz-netdev-parser/oss-fuzz-14158
Normal file
5
test/fuzz/fuzz-netdev-parser/oss-fuzz-14158
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[NetDev]
|
||||||
|
Name=w
|
||||||
|
Kind=wireguard
|
||||||
|
[WireGuard]
|
||||||
|
PrivateKey=E
|
Loading…
Reference in a new issue