summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPetr Menšík <pemensik@redhat.com>2021-08-10 22:21:01 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2021-08-10 22:21:01 +0100
commitfcb4dcaf7cc8a86ac2533b933161b6455f75bf8f (patch)
tree9f3b65c77c64415f1e96d61ef0a51cb77fae92d4 /contrib
parent3ca4995d34fb96fc7273abe7488e19f03733d7b0 (diff)
downloaddnsmasq-fcb4dcaf7cc8a86ac2533b933161b6455f75bf8f.tar.gz
Remove remaining uses of deprecated inet_addr() function.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/lease-tools/dhcp_lease_time.c10
-rw-r--r--contrib/lease-tools/dhcp_release.c3
2 files changed, 8 insertions, 5 deletions
diff --git a/contrib/lease-tools/dhcp_lease_time.c b/contrib/lease-tools/dhcp_lease_time.c
index 91edbfa..e2bad3c 100644
--- a/contrib/lease-tools/dhcp_lease_time.c
+++ b/contrib/lease-tools/dhcp_lease_time.c
@@ -153,7 +153,11 @@ int main(int argc, char **argv)
exit(1);
}
- lease.s_addr = inet_addr(argv[1]);
+ if (inet_pton(AF_INET, argv[1], &lease) < 1)
+ {
+ fprintf(stderr, "invalid address: %s\n", argv[1]);
+ exit(1);
+ }
memset(&packet, 0, sizeof(packet));
@@ -176,8 +180,8 @@ int main(int argc, char **argv)
*(p++) = OPTION_END;
- dest.sin_family = AF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ dest.sin_family = AF_INET;
+ (void)inet_pton(AF_INET, "127.0.0.1", &dest.sin_addr);
dest.sin_port = ntohs(DHCP_SERVER_PORT);
if (sendto(fd, &packet, sizeof(packet), 0,
diff --git a/contrib/lease-tools/dhcp_release.c b/contrib/lease-tools/dhcp_release.c
index 30e77c6..c1c835b 100644
--- a/contrib/lease-tools/dhcp_release.c
+++ b/contrib/lease-tools/dhcp_release.c
@@ -288,13 +288,12 @@ int main(int argc, char **argv)
exit(1);
}
- if (inet_addr(argv[2]) == INADDR_NONE)
+ if (inet_pton(AF_INET, argv[2], &lease.s_addr) < 1)
{
perror("invalid ip address");
exit(1);
}
- lease.s_addr = inet_addr(argv[2]);
server = find_interface(lease, nl, if_nametoindex(argv[1]), fd, &ifr);
memset(&packet, 0, sizeof(packet));