mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Minor improvements in lease-tools
Limit max interface name to fit into buffer. Make sure pointer have to be always positive. Close socket after received reply.
This commit is contained in:
committed by
Simon Kelley
parent
282eab7952
commit
2b38e3823b
@@ -83,7 +83,7 @@ static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt
|
|||||||
if (p >= end - 2)
|
if (p >= end - 2)
|
||||||
return NULL; /* malformed packet */
|
return NULL; /* malformed packet */
|
||||||
opt_len = option_len(p);
|
opt_len = option_len(p);
|
||||||
if (p >= end - (2 + opt_len))
|
if (end - p >= (2 + opt_len))
|
||||||
return NULL; /* malformed packet */
|
return NULL; /* malformed packet */
|
||||||
if (*p == opt && opt_len >= minsize)
|
if (*p == opt && opt_len >= minsize)
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -270,7 +270,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* This voodoo fakes up a packet coming from the correct interface, which really matters for
|
/* This voodoo fakes up a packet coming from the correct interface, which really matters for
|
||||||
a DHCP server */
|
a DHCP server */
|
||||||
strcpy(ifr.ifr_name, argv[1]);
|
strncpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name)-1);
|
||||||
|
ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) == -1)
|
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) == -1)
|
||||||
{
|
{
|
||||||
perror("cannot setup interface");
|
perror("cannot setup interface");
|
||||||
|
|||||||
@@ -376,9 +376,12 @@ int send_release_packet(const char* iface, struct dhcp6_packet* packet)
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(sock);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(sock);
|
||||||
fprintf(stderr, "Response timed out\n");
|
fprintf(stderr, "Response timed out\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user