diff options
author | Tom Gundersen <teg@jklm.no> | 2014-04-29 12:46:06 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-04-29 12:46:06 +0200 |
commit | 0b21bde96d6d33313bac42ae1d5802a83a4e7b2f (patch) | |
tree | 17466ec403b344faf0775af12a8a98c248c86087 | |
parent | 4684469639d0893d78fc8e1a1966ce11eb9c7e31 (diff) |
sd-dhcp-leaes: use newdup()
-rw-r--r-- | src/libsystemd-network/sd-dhcp-lease.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 69418d98ea..61822abd26 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -211,36 +211,24 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option, case DHCP_OPTION_DOMAIN_NAME_SERVER: if (len && !(len % 4)) { - unsigned i; - lease->dns_size = len / 4; free(lease->dns); - lease->dns = new0(struct in_addr, lease->dns_size); + lease->dns = newdup(struct in_addr, option, lease->dns_size); if (!lease->dns) return -ENOMEM; - - for (i = 0; i < lease->dns_size; i++) { - memcpy(&lease->dns[i].s_addr, option + 4 * i, 4); - } } break; case DHCP_OPTION_NTP_SERVER: if (len && !(len % 4)) { - unsigned i; - lease->ntp_size = len / 4; free(lease->ntp); - lease->ntp = new0(struct in_addr, lease->ntp_size); + lease->ntp = newdup(struct in_addr, option, lease->ntp_size); if (!lease->ntp) return -ENOMEM; - - for (i = 0; i < lease->ntp_size; i++) { - memcpy(&lease->ntp[i].s_addr, option + 4 * i, 4); - } } break; |