diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-06-09 15:21:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 15:21:57 +0900 |
commit | 377157e6bd743af8de1e89b6109282de4fc5a066 (patch) | |
tree | 956cb80f189728444cadff330466cea0983daa76 /src/machine | |
parent | 295e0291bff52a12d4ce7d7481c4da464002fbb6 (diff) | |
parent | 89eb3d7c95b8dc3d40471b73699c464994769844 (diff) | |
download | systemd-377157e6bd743af8de1e89b6109282de4fc5a066.tar.gz |
Merge pull request #23616 from keszybz/in-addr-to-string-formatting
Add macros that allocate a fixed buffer for in_addr_to_string(), in_addr_prefix+to_string()
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machinectl.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 22693dad0a..34d1d9dd8e 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -192,7 +192,7 @@ static int call_get_addresses( int family; const void *a; size_t sz; - char buf_ifi[DECIMAL_STR_MAX(int) + 2], buffer[MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)]; + char buf_ifi[1 + DECIMAL_STR_MAX(int)] = ""; r = sd_bus_message_read(reply, "i", &family); if (r < 0) @@ -204,13 +204,8 @@ static int call_get_addresses( if (family == AF_INET6 && ifi > 0) xsprintf(buf_ifi, "%%%i", ifi); - else - strcpy(buf_ifi, ""); - if (!strextend(&addresses, - prefix, - inet_ntop(family, a, buffer, sizeof(buffer)), - buf_ifi)) + if (!strextend(&addresses, prefix, IN_ADDR_TO_STRING(family, a), buf_ifi)) return log_oom(); r = sd_bus_message_exit_container(reply); |