Sean MacLennan
2018-11-13 00:05:38 UTC
I am surprised you are getting away with binding the socket to the
broadcast address. The other bug is just a simple compiler warning.
diff --git a/sdhcp.c b/sdhcp.c
index e2a641e..47cabf6 100644
--- a/sdhcp.c
+++ b/sdhcp.c
@@ -467,7 +467,7 @@ main(int argc, char *argv[])
if (argc)
ifname = argv[0]; /* interface name */
if (argc >= 2)
- strlcpy(cid, argv[1], sizeof(cid)); /* client-id */
+ strlcpy((char *)cid, argv[1], sizeof(cid)); /* client-id */
memset(&ifreq, 0, sizeof(ifreq));
signal(SIGALRM, nop);
@@ -482,7 +482,7 @@ main(int argc, char *argv[])
ioctl(sock, SIOCGIFINDEX, &ifreq);
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &ifreq, sizeof ifreq) == -1)
eprintf("setsockopt:");
- iptoaddr(&addr, IP(255, 255, 255, 255), 68);
+ iptoaddr(&addr, IP(0, 0, 0, 0), 68);
if (bind(sock, (void*)&addr, sizeof addr) != 0)
eprintf("bind:");
ioctl(sock, SIOCGIFHWADDR, &ifreq);
broadcast address. The other bug is just a simple compiler warning.
diff --git a/sdhcp.c b/sdhcp.c
index e2a641e..47cabf6 100644
--- a/sdhcp.c
+++ b/sdhcp.c
@@ -467,7 +467,7 @@ main(int argc, char *argv[])
if (argc)
ifname = argv[0]; /* interface name */
if (argc >= 2)
- strlcpy(cid, argv[1], sizeof(cid)); /* client-id */
+ strlcpy((char *)cid, argv[1], sizeof(cid)); /* client-id */
memset(&ifreq, 0, sizeof(ifreq));
signal(SIGALRM, nop);
@@ -482,7 +482,7 @@ main(int argc, char *argv[])
ioctl(sock, SIOCGIFINDEX, &ifreq);
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &ifreq, sizeof ifreq) == -1)
eprintf("setsockopt:");
- iptoaddr(&addr, IP(255, 255, 255, 255), 68);
+ iptoaddr(&addr, IP(0, 0, 0, 0), 68);
if (bind(sock, (void*)&addr, sizeof addr) != 0)
eprintf("bind:");
ioctl(sock, SIOCGIFHWADDR, &ifreq);