From 94af46fc66779ddaaff09c4dc704637c3158a3c5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 18 Feb 2021 03:27:35 +0900 Subject: [PATCH] network: use temporary buffer for safety --- src/network/networkd-address.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 96c9376bede..f55f9fafbe7 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -1457,6 +1457,7 @@ int config_parse_broadcast( Network *network = userdata; _cleanup_(address_free_or_set_invalidp) Address *n = NULL; + union in_addr_union u; int r; assert(filename); @@ -1480,13 +1481,14 @@ int config_parse_broadcast( return 0; } - r = in_addr_from_string(AF_INET, rvalue, (union in_addr_union*) &n->broadcast); + r = in_addr_from_string(AF_INET, rvalue, &u); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Broadcast is invalid, ignoring assignment: %s", rvalue); return 0; } + n->broadcast = u.in; n->family = AF_INET; TAKE_PTR(n);