diff options
author | Dan Winship <danw@redhat.com> | 2014-11-18 08:59:42 -0500 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-12-09 09:38:13 +0100 |
commit | fbf7dcb5886f4077ee0dea618447ab488ff148fc (patch) | |
tree | e52569ef824b5cbb8c87e204b2bcab5cde598dff /src/libsystemd-network/network-internal.c | |
parent | a5ccdb9884a730553bce96b6d041b28da30d668f (diff) |
libsystemd-network: fix writing of routes in dhcp lease file
inet_ntoa() uses a static buffer, so you can't call it twice in the
same fprintf() call.
Diffstat (limited to 'src/libsystemd-network/network-internal.c')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 90f830a351..6852a7129a 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -392,10 +392,12 @@ void serialize_dhcp_routes(FILE *f, const char *key, struct sd_dhcp_route *route fprintf(f, "%s=", key); - for (i = 0; i < size; i++) - fprintf(f, "%s/%" PRIu8 ",%s%s", inet_ntoa(routes[i].dst_addr), - routes[i].dst_prefixlen, inet_ntoa(routes[i].gw_addr), + for (i = 0; i < size; i++) { + fprintf(f, "%s/%" PRIu8, inet_ntoa(routes[i].dst_addr), + routes[i].dst_prefixlen); + fprintf(f, ",%s%s", inet_ntoa(routes[i].gw_addr), (i < (size - 1)) ? " ": ""); + } fputs("\n", f); } |