mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a610a007f | ||
|
|
48b090cb5c | ||
|
|
4139298d28 | ||
|
|
51cc10fa54 | ||
|
|
ea6cc33804 | ||
|
|
ad03967ee4 | ||
|
|
f4fd07d303 | ||
|
|
e3c08a34a7 | ||
|
|
118011fe2b | ||
|
|
af3bd07355 | ||
|
|
d68209978a | ||
|
|
47b45b2967 | ||
|
|
2b38e3823b | ||
|
|
282eab7952 | ||
|
|
c346f61535 | ||
|
|
03212e533b |
No files matched your search
@@ -59,6 +59,11 @@ version 2.80
|
|||||||
Returning null addresses is a useful technique for ad-blocking.
|
Returning null addresses is a useful technique for ad-blocking.
|
||||||
Thanks to Peter Russell for the suggestion.
|
Thanks to Peter Russell for the suggestion.
|
||||||
|
|
||||||
|
Change anti cache-snooping behaviour with queries with the
|
||||||
|
recursion-desired bit unset. Instead to returning SERVFAIL, we
|
||||||
|
now always forward, and never answer from the cache. This
|
||||||
|
allows "dig +trace" command to work.
|
||||||
|
|
||||||
|
|
||||||
version 2.79
|
version 2.79
|
||||||
Fix parsing of CNAME arguments, which are confused by extra spaces.
|
Fix parsing of CNAME arguments, which are confused by extra spaces.
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+9
@@ -1,3 +1,12 @@
|
|||||||
|
dnsmasq (2.80-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream. (closes: #837602) (closes: #794640) (closes: #794636)
|
||||||
|
* Close old bugs, long agp fixed. (closes: #802845) (closes: #754299)
|
||||||
|
* Provide usr/lib/tmpfiles.d/dnsmasq.conf. (closes: #872396)
|
||||||
|
* Run restorecon on /run/dnsmasq for SE Linux. (closes: #872397)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Mon, 17 Sep 2018 23:11:25 +0000
|
||||||
|
|
||||||
dnsmasq (2.79-1) unstable; urgency=low
|
dnsmasq (2.79-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream. (closes: #888200)
|
* New upstream. (closes: #888200)
|
||||||
|
|||||||
Vendored
+1
@@ -127,6 +127,7 @@ start()
|
|||||||
mkdir /run/dnsmasq || return 2
|
mkdir /run/dnsmasq || return 2
|
||||||
chown dnsmasq:nogroup /run/dnsmasq || return 2
|
chown dnsmasq:nogroup /run/dnsmasq || return 2
|
||||||
fi
|
fi
|
||||||
|
[ -x /sbin/restorecon ] && /sbin/restorecon /run/dnsmasq
|
||||||
|
|
||||||
start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null || return 1
|
start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null || return 1
|
||||||
start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON -- \
|
start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON -- \
|
||||||
|
|||||||
Vendored
+2
@@ -169,6 +169,7 @@ binary-indep: checkroot
|
|||||||
-d debian/trees/daemon/usr/share/dnsmasq \
|
-d debian/trees/daemon/usr/share/dnsmasq \
|
||||||
-d debian/trees/daemon/etc/default \
|
-d debian/trees/daemon/etc/default \
|
||||||
-d debian/trees/daemon/lib/systemd/system \
|
-d debian/trees/daemon/lib/systemd/system \
|
||||||
|
-d debian/trees/daemon/usr/lib/tmpfiles.d \
|
||||||
-d debian/trees/daemon/etc/insserv.conf.d
|
-d debian/trees/daemon/etc/insserv.conf.d
|
||||||
install -m 644 debian/conffiles debian/trees/daemon/DEBIAN
|
install -m 644 debian/conffiles debian/trees/daemon/DEBIAN
|
||||||
install -m 755 debian/postinst debian/postrm debian/prerm debian/trees/daemon/DEBIAN
|
install -m 755 debian/postinst debian/postrm debian/prerm debian/trees/daemon/DEBIAN
|
||||||
@@ -180,6 +181,7 @@ binary-indep: checkroot
|
|||||||
install -m 644 dnsmasq.conf.example debian/trees/daemon/etc/dnsmasq.conf
|
install -m 644 dnsmasq.conf.example debian/trees/daemon/etc/dnsmasq.conf
|
||||||
install -m 644 debian/readme.dnsmasq.d debian/trees/daemon/etc/dnsmasq.d/README
|
install -m 644 debian/readme.dnsmasq.d debian/trees/daemon/etc/dnsmasq.d/README
|
||||||
install -m 644 debian/systemd.service debian/trees/daemon/lib/systemd/system/dnsmasq.service
|
install -m 644 debian/systemd.service debian/trees/daemon/lib/systemd/system/dnsmasq.service
|
||||||
|
install -m 644 debian/tmpfiles.conf debian/trees/daemon/usr/lib/tmpfiles.d/dnsmasq.conf
|
||||||
install -m 644 debian/insserv debian/trees/daemon/etc/insserv.conf.d/dnsmasq
|
install -m 644 debian/insserv debian/trees/daemon/etc/insserv.conf.d/dnsmasq
|
||||||
ln -s $(package) debian/trees/daemon/usr/share/doc/dnsmasq
|
ln -s $(package) debian/trees/daemon/usr/share/doc/dnsmasq
|
||||||
cd debian/trees/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
|
cd debian/trees/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
d /run/dnsmasq 755 dnsmasq nogroup
|
||||||
+3
-3
@@ -27,7 +27,7 @@ TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP. The PXE
|
|||||||
.PP
|
.PP
|
||||||
The dnsmasq DHCPv6 server provides the same set of features as the
|
The dnsmasq DHCPv6 server provides the same set of features as the
|
||||||
DHCPv4 server, and in addition, it includes router advertisements and
|
DHCPv4 server, and in addition, it includes router advertisements and
|
||||||
a neat feature which allows nameing for clients which use DHCPv4 and
|
a neat feature which allows naming for clients which use DHCPv4 and
|
||||||
stateless autoconfiguration only for IPv6 configuration. There is support for doing address allocation (both DHCPv6 and RA) from subnets which are dynamically delegated via DHCPv6 prefix delegation.
|
stateless autoconfiguration only for IPv6 configuration. There is support for doing address allocation (both DHCPv6 and RA) from subnets which are dynamically delegated via DHCPv6 prefix delegation.
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq is coded with small embedded systems in mind. It aims for the smallest possible memory footprint compatible with the supported functions, and allows unneeded functions to be omitted from the compiled binary.
|
Dnsmasq is coded with small embedded systems in mind. It aims for the smallest possible memory footprint compatible with the supported functions, and allows unneeded functions to be omitted from the compiled binary.
|
||||||
@@ -156,7 +156,7 @@ can be over-ridden with this switch.
|
|||||||
.TP
|
.TP
|
||||||
.B \-g, --group=<groupname>
|
.B \-g, --group=<groupname>
|
||||||
Specify the group which dnsmasq will run
|
Specify the group which dnsmasq will run
|
||||||
as. The defaults to "dip", if available, to facilitate access to
|
as. The default is "dip", if available, to facilitate access to
|
||||||
/etc/ppp/resolv.conf which is not normally world readable.
|
/etc/ppp/resolv.conf which is not normally world readable.
|
||||||
.TP
|
.TP
|
||||||
.B \-v, --version
|
.B \-v, --version
|
||||||
@@ -515,7 +515,7 @@ address of 0.0.0.0 and its IPv6 equivalent of :: so
|
|||||||
\fB--address=/example.com/#\fP will return NULL addresses for example.com and
|
\fB--address=/example.com/#\fP will return NULL addresses for example.com and
|
||||||
its subdomains. This is partly syntactic sugar for \fB--address=/example.com/0.0.0.0\fP
|
its subdomains. This is partly syntactic sugar for \fB--address=/example.com/0.0.0.0\fP
|
||||||
and \fB--address=/example.com/::\fP but is also more efficient than including both
|
and \fB--address=/example.com/::\fP but is also more efficient than including both
|
||||||
as seperate configuration lines.
|
as seperate configuration lines. Note that NULL addresses normally work in the same way as localhost, so beware that clients looking up these names are likely to end up talking to themselves.
|
||||||
.TP
|
.TP
|
||||||
.B --ipset=/<domain>[/<domain>...]/<ipset>[,<ipset>...]
|
.B --ipset=/<domain>[/<domain>...]/<ipset>[,<ipset>...]
|
||||||
Places the resolved IP addresses of queries for one or more domains in
|
Places the resolved IP addresses of queries for one or more domains in
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
struct in6_ifreq ifr6;
|
struct in6_ifreq ifr6;
|
||||||
|
|
||||||
memset(&ifr6, 0, sizeof(ifr6));
|
memset(&ifr6, 0, sizeof(ifr6));
|
||||||
strncpy(ifr6.ifr_name, addrs->ifa_name, sizeof(ifr6.ifr_name));
|
safe_strncpy(ifr6.ifr_name, addrs->ifa_name, sizeof(ifr6.ifr_name));
|
||||||
|
|
||||||
ifr6.ifr_addr = *((struct sockaddr_in6 *) addrs->ifa_addr);
|
ifr6.ifr_addr = *((struct sockaddr_in6 *) addrs->ifa_addr);
|
||||||
if (fd != -1 && ioctl(fd, SIOCGIFAFLAG_IN6, &ifr6) != -1)
|
if (fd != -1 && ioctl(fd, SIOCGIFAFLAG_IN6, &ifr6) != -1)
|
||||||
|
|||||||
+18
-17
@@ -825,7 +825,7 @@ static void add_hosts_cname(struct crec *target)
|
|||||||
for (a = daemon->cnames; a; a = a->next)
|
for (a = daemon->cnames; a; a = a->next)
|
||||||
if (a->alias[1] != '*' &&
|
if (a->alias[1] != '*' &&
|
||||||
hostname_isequal(cache_get_name(target), a->target) &&
|
hostname_isequal(cache_get_name(target), a->target) &&
|
||||||
(crec = whine_malloc(sizeof(struct crec))))
|
(crec = whine_malloc(SIZEOF_POINTER_CREC)))
|
||||||
{
|
{
|
||||||
crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_CONFIG | F_CNAME;
|
crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_CONFIG | F_CNAME;
|
||||||
crec->ttd = a->ttl;
|
crec->ttd = a->ttl;
|
||||||
@@ -1029,8 +1029,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
{
|
{
|
||||||
/* If set, add a version of the name with a default domain appended */
|
/* If set, add a version of the name with a default domain appended */
|
||||||
if (option_bool(OPT_EXPAND) && domain_suffix && !fqdn &&
|
if (option_bool(OPT_EXPAND) && domain_suffix && !fqdn &&
|
||||||
(cache = whine_malloc(sizeof(struct crec) +
|
(cache = whine_malloc(SIZEOF_BARE_CREC + strlen(canon) + 2 + strlen(domain_suffix))))
|
||||||
strlen(canon)+2+strlen(domain_suffix)-SMALLDNAME)))
|
|
||||||
{
|
{
|
||||||
strcpy(cache->name.sname, canon);
|
strcpy(cache->name.sname, canon);
|
||||||
strcat(cache->name.sname, ".");
|
strcat(cache->name.sname, ".");
|
||||||
@@ -1040,7 +1039,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
||||||
name_count++;
|
name_count++;
|
||||||
}
|
}
|
||||||
if ((cache = whine_malloc(sizeof(struct crec) + strlen(canon)+1-SMALLDNAME)))
|
if ((cache = whine_malloc(SIZEOF_BARE_CREC + strlen(canon) + 1)))
|
||||||
{
|
{
|
||||||
strcpy(cache->name.sname, canon);
|
strcpy(cache->name.sname, canon);
|
||||||
cache->flags = flags;
|
cache->flags = flags;
|
||||||
@@ -1113,7 +1112,7 @@ void cache_reload(void)
|
|||||||
for (intr = daemon->int_names; intr; intr = intr->next)
|
for (intr = daemon->int_names; intr; intr = intr->next)
|
||||||
if (a->alias[1] != '*' &&
|
if (a->alias[1] != '*' &&
|
||||||
hostname_isequal(a->target, intr->name) &&
|
hostname_isequal(a->target, intr->name) &&
|
||||||
((cache = whine_malloc(sizeof(struct crec)))))
|
((cache = whine_malloc(SIZEOF_POINTER_CREC))))
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
||||||
cache->ttd = a->ttl;
|
cache->ttd = a->ttl;
|
||||||
@@ -1128,7 +1127,7 @@ void cache_reload(void)
|
|||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
for (ds = daemon->ds; ds; ds = ds->next)
|
for (ds = daemon->ds; ds; ds = ds->next)
|
||||||
if ((cache = whine_malloc(sizeof(struct crec))) &&
|
if ((cache = whine_malloc(SIZEOF_POINTER_CREC)) &&
|
||||||
(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
||||||
@@ -1155,7 +1154,7 @@ void cache_reload(void)
|
|||||||
for (nl = hr->names; nl; nl = nl->next)
|
for (nl = hr->names; nl; nl = nl->next)
|
||||||
{
|
{
|
||||||
if (hr->addr.s_addr != 0 &&
|
if (hr->addr.s_addr != 0 &&
|
||||||
(cache = whine_malloc(sizeof(struct crec))))
|
(cache = whine_malloc(SIZEOF_POINTER_CREC)))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->ttd = hr->ttl;
|
cache->ttd = hr->ttl;
|
||||||
@@ -1164,7 +1163,7 @@ void cache_reload(void)
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
|
if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
|
||||||
(cache = whine_malloc(sizeof(struct crec))))
|
(cache = whine_malloc(SIZEOF_POINTER_CREC)))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->ttd = hr->ttl;
|
cache->ttd = hr->ttl;
|
||||||
@@ -1241,7 +1240,7 @@ static void add_dhcp_cname(struct crec *target, time_t ttd)
|
|||||||
if ((aliasc = dhcp_spare))
|
if ((aliasc = dhcp_spare))
|
||||||
dhcp_spare = dhcp_spare->next;
|
dhcp_spare = dhcp_spare->next;
|
||||||
else /* need new one */
|
else /* need new one */
|
||||||
aliasc = whine_malloc(sizeof(struct crec));
|
aliasc = whine_malloc(SIZEOF_POINTER_CREC);
|
||||||
|
|
||||||
if (aliasc)
|
if (aliasc)
|
||||||
{
|
{
|
||||||
@@ -1332,7 +1331,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
if ((crec = dhcp_spare))
|
if ((crec = dhcp_spare))
|
||||||
dhcp_spare = dhcp_spare->next;
|
dhcp_spare = dhcp_spare->next;
|
||||||
else /* need new one */
|
else /* need new one */
|
||||||
crec = whine_malloc(sizeof(struct crec));
|
crec = whine_malloc(SIZEOF_POINTER_CREC);
|
||||||
|
|
||||||
if (crec) /* malloc may fail */
|
if (crec) /* malloc may fail */
|
||||||
{
|
{
|
||||||
@@ -1360,7 +1359,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
static void make_non_terminals(struct crec *source)
|
static void make_non_terminals(struct crec *source)
|
||||||
{
|
{
|
||||||
char *name = cache_get_name(source);
|
char *name = cache_get_name(source);
|
||||||
struct crec* crecp, *tmp, **up;
|
struct crec *crecp, *tmp, **up;
|
||||||
int type = F_HOSTS | F_CONFIG;
|
int type = F_HOSTS | F_CONFIG;
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (source->flags & F_DHCP)
|
if (source->flags & F_DHCP)
|
||||||
@@ -1432,14 +1431,16 @@ static void make_non_terminals(struct crec *source)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
crecp = whine_malloc(sizeof(struct crec));
|
crecp = whine_malloc(SIZEOF_POINTER_CREC);
|
||||||
|
|
||||||
*crecp = *source;
|
if (crecp)
|
||||||
crecp->flags &= ~(F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_REVERSE);
|
{
|
||||||
crecp->flags |= F_NAMEP;
|
crecp->flags = (source->flags | F_NAMEP) & ~(F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_REVERSE);
|
||||||
crecp->name.namep = name;
|
crecp->ttd = source->ttd;
|
||||||
|
crecp->name.namep = name;
|
||||||
|
|
||||||
cache_hash(crecp);
|
cache_hash(crecp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -485,8 +485,11 @@ char *whichdevice(void)
|
|||||||
|
|
||||||
void bindtodevice(char *device, int fd)
|
void bindtodevice(char *device, int fd)
|
||||||
{
|
{
|
||||||
|
size_t len = strlen(device)+1;
|
||||||
|
if (len > IFNAMSIZ)
|
||||||
|
len = IFNAMSIZ;
|
||||||
/* only allowed by root. */
|
/* only allowed by root. */
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, device, IFNAMSIZ) == -1 &&
|
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, device, len) == -1 &&
|
||||||
errno != EPERM)
|
errno != EPERM)
|
||||||
die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET);
|
die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -232,7 +232,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
/* ARP fiddling uses original interface even if we pretend to use a different one. */
|
/* ARP fiddling uses original interface even if we pretend to use a different one. */
|
||||||
strncpy(arp_req.arp_dev, ifr.ifr_name, 16);
|
safe_strncpy(arp_req.arp_dev, ifr.ifr_name, sizeof(arp_req.arp_dev));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If the interface on which the DHCP request was received is an
|
/* If the interface on which the DHCP request was received is an
|
||||||
@@ -255,7 +255,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(ifr.ifr_name, bridge->iface, IF_NAMESIZE);
|
safe_strncpy(ifr.ifr_name, bridge->iface, sizeof(ifr.ifr_name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
is_relay_reply = 1;
|
is_relay_reply = 1;
|
||||||
iov.iov_len = sz;
|
iov.iov_len = sz;
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
strncpy(arp_req.arp_dev, ifr.ifr_name, 16);
|
safe_strncpy(arp_req.arp_dev, ifr.ifr_name, sizeof(arp_req.arp_dev));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -988,8 +988,7 @@ char *host_from_dns(struct in_addr addr)
|
|||||||
if (!legal_hostname(hostname))
|
if (!legal_hostname(hostname))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strncpy(daemon->dhcp_buff, hostname, 256);
|
safe_strncpy(daemon->dhcp_buff, hostname, 256);
|
||||||
daemon->dhcp_buff[255] = 0;
|
|
||||||
strip_hostname(daemon->dhcp_buff);
|
strip_hostname(daemon->dhcp_buff);
|
||||||
|
|
||||||
return daemon->dhcp_buff;
|
return daemon->dhcp_buff;
|
||||||
|
|||||||
+11
-1
@@ -42,6 +42,12 @@
|
|||||||
# define __EXTENSIONS__
|
# define __EXTENSIONS__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__GNUC__) && __GNUC__ >= 3) || defined(__clang__)
|
||||||
|
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
|
||||||
|
#else
|
||||||
|
#define ATTRIBUTE_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
/* get these before config.h for IPv6 stuff... */
|
/* get these before config.h for IPv6 stuff... */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -436,6 +442,9 @@ struct crec {
|
|||||||
} name;
|
} name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SIZEOF_BARE_CREC (sizeof(struct crec) - SMALLDNAME)
|
||||||
|
#define SIZEOF_POINTER_CREC (sizeof(struct crec) + sizeof(char *) - SMALLDNAME)
|
||||||
|
|
||||||
#define F_IMMORTAL (1u<<0)
|
#define F_IMMORTAL (1u<<0)
|
||||||
#define F_NAMEP (1u<<1)
|
#define F_NAMEP (1u<<1)
|
||||||
#define F_REVERSE (1u<<2)
|
#define F_REVERSE (1u<<2)
|
||||||
@@ -1246,6 +1255,7 @@ int legal_hostname(char *name);
|
|||||||
char *canonicalise(char *in, int *nomem);
|
char *canonicalise(char *in, int *nomem);
|
||||||
unsigned char *do_rfc1035_name(unsigned char *p, char *sval, char *limit);
|
unsigned char *do_rfc1035_name(unsigned char *p, char *sval, char *limit);
|
||||||
void *safe_malloc(size_t size);
|
void *safe_malloc(size_t size);
|
||||||
|
void safe_strncpy(char *dest, const char *src, size_t size);
|
||||||
void safe_pipe(int *fd, int read_noblock);
|
void safe_pipe(int *fd, int read_noblock);
|
||||||
void *whine_malloc(size_t size);
|
void *whine_malloc(size_t size);
|
||||||
int sa_len(union mysockaddr *addr);
|
int sa_len(union mysockaddr *addr);
|
||||||
@@ -1275,7 +1285,7 @@ int wildcard_match(const char* wildcard, const char* match);
|
|||||||
int wildcard_matchn(const char* wildcard, const char* match, int num);
|
int wildcard_matchn(const char* wildcard, const char* match, int num);
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
void die(char *message, char *arg1, int exit_code);
|
void die(char *message, char *arg1, int exit_code) ATTRIBUTE_NORETURN;
|
||||||
int log_start(struct passwd *ent_pw, int errfd);
|
int log_start(struct passwd *ent_pw, int errfd);
|
||||||
int log_reopen(char *log_file);
|
int log_reopen(char *log_file);
|
||||||
|
|
||||||
|
|||||||
+12
-6
@@ -229,12 +229,18 @@ static unsigned int search_servers(time_t now, struct all_addr **addrpp, unsigne
|
|||||||
|
|
||||||
if (flags)
|
if (flags)
|
||||||
{
|
{
|
||||||
int logflags = 0;
|
if (flags == F_NXDOMAIN || flags == F_NOERR)
|
||||||
|
log_query(flags | qtype | F_NEG | F_CONFIG | F_FORWARD, qdomain, NULL, NULL);
|
||||||
if (flags == F_NXDOMAIN || flags == F_NOERR)
|
else
|
||||||
logflags = F_NEG | qtype;
|
{
|
||||||
|
/* handle F_IPV4 and F_IPV6 set on ANY query to 0.0.0.0/:: domain. */
|
||||||
log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp, NULL);
|
if (flags & F_IPV4)
|
||||||
|
log_query((flags | F_CONFIG | F_FORWARD) & ~F_IPV6, qdomain, *addrpp, NULL);
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (flags & F_IPV6)
|
||||||
|
log_query((flags | F_CONFIG | F_FORWARD) & ~F_IPV4, qdomain, *addrpp, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((*type) & SERV_USE_RESOLV)
|
else if ((*type) & SERV_USE_RESOLV)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ static void log_write(void)
|
|||||||
logaddr.sun_len = sizeof(logaddr) - sizeof(logaddr.sun_path) + strlen(_PATH_LOG) + 1;
|
logaddr.sun_len = sizeof(logaddr) - sizeof(logaddr.sun_path) + strlen(_PATH_LOG) + 1;
|
||||||
#endif
|
#endif
|
||||||
logaddr.sun_family = AF_UNIX;
|
logaddr.sun_family = AF_UNIX;
|
||||||
strncpy(logaddr.sun_path, _PATH_LOG, sizeof(logaddr.sun_path));
|
safe_strncpy(logaddr.sun_path, _PATH_LOG, sizeof(logaddr.sun_path));
|
||||||
|
|
||||||
/* Got connection back? try again. */
|
/* Got connection back? try again. */
|
||||||
if (connect(log_fd, (struct sockaddr *)&logaddr, sizeof(logaddr)) != -1)
|
if (connect(log_fd, (struct sockaddr *)&logaddr, sizeof(logaddr)) != -1)
|
||||||
|
|||||||
+3
-3
@@ -149,10 +149,10 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
struct rtgenmsg g;
|
struct rtgenmsg g;
|
||||||
} req;
|
} req;
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
|
||||||
addr.nl_family = AF_NETLINK;
|
addr.nl_family = AF_NETLINK;
|
||||||
addr.nl_pad = 0;
|
|
||||||
addr.nl_groups = 0;
|
|
||||||
addr.nl_pid = 0; /* address to kernel */
|
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if (family == AF_UNSPEC)
|
if (family == AF_UNSPEC)
|
||||||
|
|||||||
+6
-6
@@ -29,7 +29,7 @@ int indextoname(int fd, int index, char *name)
|
|||||||
if (ioctl(fd, SIOCGIFNAME, &ifr) == -1)
|
if (ioctl(fd, SIOCGIFNAME, &ifr) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
strncpy(name, ifr.ifr_name, IF_NAMESIZE);
|
safe_strncpy(name, ifr.ifr_name, IF_NAMESIZE);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -82,12 +82,12 @@ int indextoname(int fd, int index, char *name)
|
|||||||
for (i = lifc.lifc_len / sizeof(struct lifreq); i; i--, lifrp++)
|
for (i = lifc.lifc_len / sizeof(struct lifreq); i; i--, lifrp++)
|
||||||
{
|
{
|
||||||
struct lifreq lifr;
|
struct lifreq lifr;
|
||||||
strncpy(lifr.lifr_name, lifrp->lifr_name, IF_NAMESIZE);
|
safe_strncpy(lifr.lifr_name, lifrp->lifr_name, IF_NAMESIZE);
|
||||||
if (ioctl(fd, SIOCGLIFINDEX, &lifr) < 0)
|
if (ioctl(fd, SIOCGLIFINDEX, &lifr) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (lifr.lifr_index == index) {
|
if (lifr.lifr_index == index) {
|
||||||
strncpy(name, lifr.lifr_name, IF_NAMESIZE);
|
safe_strncpy(name, lifr.lifr_name, IF_NAMESIZE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ int loopback_exception(int fd, int family, struct all_addr *addr, char *name)
|
|||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
|
|
||||||
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
safe_strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
||||||
if (ioctl(fd, SIOCGIFFLAGS, &ifr) != -1 &&
|
if (ioctl(fd, SIOCGIFFLAGS, &ifr) != -1 &&
|
||||||
ifr.ifr_flags & IFF_LOOPBACK)
|
ifr.ifr_flags & IFF_LOOPBACK)
|
||||||
{
|
{
|
||||||
@@ -1286,7 +1286,7 @@ static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(sfd->interface, intname);
|
safe_strncpy(sfd->interface, intname, sizeof(sfd->interface));
|
||||||
sfd->source_addr = *addr;
|
sfd->source_addr = *addr;
|
||||||
sfd->next = daemon->sfds;
|
sfd->next = daemon->sfds;
|
||||||
sfd->ifindex = ifindex;
|
sfd->ifindex = ifindex;
|
||||||
@@ -1458,7 +1458,7 @@ void add_update_server(int flags,
|
|||||||
serv->flags |= SERV_HAS_DOMAIN;
|
serv->flags |= SERV_HAS_DOMAIN;
|
||||||
|
|
||||||
if (interface)
|
if (interface)
|
||||||
strcpy(serv->interface, interface);
|
safe_strncpy(serv->interface, interface, sizeof(serv->interface));
|
||||||
if (addr)
|
if (addr)
|
||||||
serv->addr = *addr;
|
serv->addr = *addr;
|
||||||
if (source_addr)
|
if (source_addr)
|
||||||
|
|||||||
+4
-5
@@ -810,7 +810,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
|
|||||||
if (interface_opt)
|
if (interface_opt)
|
||||||
{
|
{
|
||||||
#if defined(SO_BINDTODEVICE)
|
#if defined(SO_BINDTODEVICE)
|
||||||
strncpy(interface, interface_opt, IF_NAMESIZE - 1);
|
safe_strncpy(interface, interface_opt, IF_NAMESIZE);
|
||||||
#else
|
#else
|
||||||
return _("interface binding not supported");
|
return _("interface binding not supported");
|
||||||
#endif
|
#endif
|
||||||
@@ -839,7 +839,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
|
|||||||
return _("interface can only be specified once");
|
return _("interface can only be specified once");
|
||||||
|
|
||||||
source_addr->in.sin_addr.s_addr = INADDR_ANY;
|
source_addr->in.sin_addr.s_addr = INADDR_ANY;
|
||||||
strncpy(interface, source, IF_NAMESIZE - 1);
|
safe_strncpy(interface, source, IF_NAMESIZE);
|
||||||
#else
|
#else
|
||||||
return _("interface binding not supported");
|
return _("interface binding not supported");
|
||||||
#endif
|
#endif
|
||||||
@@ -874,7 +874,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
|
|||||||
return _("interface can only be specified once");
|
return _("interface can only be specified once");
|
||||||
|
|
||||||
source_addr->in6.sin6_addr = in6addr_any;
|
source_addr->in6.sin6_addr = in6addr_any;
|
||||||
strncpy(interface, source, IF_NAMESIZE - 1);
|
safe_strncpy(interface, source, IF_NAMESIZE);
|
||||||
#else
|
#else
|
||||||
return _("interface binding not supported");
|
return _("interface binding not supported");
|
||||||
#endif
|
#endif
|
||||||
@@ -4801,8 +4801,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
argbuf_size = strlen(optarg) + 1;
|
argbuf_size = strlen(optarg) + 1;
|
||||||
argbuf = opt_malloc(argbuf_size);
|
argbuf = opt_malloc(argbuf_size);
|
||||||
}
|
}
|
||||||
strncpy(argbuf, optarg, argbuf_size);
|
safe_strncpy(argbuf, optarg, argbuf_size);
|
||||||
argbuf[argbuf_size-1] = 0;
|
|
||||||
arg = argbuf;
|
arg = argbuf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+21
-19
@@ -956,22 +956,26 @@ size_t setup_reply(struct dns_header *header, size_t qlen,
|
|||||||
log_query(F_CONFIG | F_RCODE, "error", &a, NULL);
|
log_query(F_CONFIG | F_RCODE, "error", &a, NULL);
|
||||||
SET_RCODE(header, SERVFAIL);
|
SET_RCODE(header, SERVFAIL);
|
||||||
}
|
}
|
||||||
else if (flags == F_IPV4)
|
else if (flags & ( F_IPV4 | F_IPV6))
|
||||||
{ /* we know the address */
|
|
||||||
SET_RCODE(header, NOERROR);
|
|
||||||
header->ancount = htons(1);
|
|
||||||
header->hb3 |= HB3_AA;
|
|
||||||
add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_A, C_IN, "4", addrp);
|
|
||||||
}
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
else if (flags == F_IPV6)
|
|
||||||
{
|
{
|
||||||
SET_RCODE(header, NOERROR);
|
if (flags & F_IPV4)
|
||||||
header->ancount = htons(1);
|
{ /* we know the address */
|
||||||
header->hb3 |= HB3_AA;
|
SET_RCODE(header, NOERROR);
|
||||||
add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_AAAA, C_IN, "6", addrp);
|
header->ancount = htons(1);
|
||||||
}
|
header->hb3 |= HB3_AA;
|
||||||
|
add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_A, C_IN, "4", addrp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (flags & F_IPV6)
|
||||||
|
{
|
||||||
|
SET_RCODE(header, NOERROR);
|
||||||
|
header->ancount = htons(ntohs(header->ancount) + 1);
|
||||||
|
header->hb3 |= HB3_AA;
|
||||||
|
add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_AAAA, C_IN, "6", addrp);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
else /* nowhere to forward to */
|
else /* nowhere to forward to */
|
||||||
{
|
{
|
||||||
struct all_addr a;
|
struct all_addr a;
|
||||||
@@ -1289,16 +1293,14 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
struct mx_srv_record *rec;
|
struct mx_srv_record *rec;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (ntohs(header->ancount) != 0 ||
|
/* never answer queries with RD unset, to avoid cache snooping. */
|
||||||
|
if (!(header->hb3 & HB3_RD) ||
|
||||||
|
ntohs(header->ancount) != 0 ||
|
||||||
ntohs(header->nscount) != 0 ||
|
ntohs(header->nscount) != 0 ||
|
||||||
ntohs(header->qdcount) == 0 ||
|
ntohs(header->qdcount) == 0 ||
|
||||||
OPCODE(header) != QUERY )
|
OPCODE(header) != QUERY )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* always servfail queries with RD unset, to avoid cache snooping. */
|
|
||||||
if (!(header->hb3 & HB3_RD))
|
|
||||||
return setup_reply(header, qlen, NULL, F_SERVFAIL, 0);
|
|
||||||
|
|
||||||
/* Don't return AD set if checking disabled. */
|
/* Don't return AD set if checking disabled. */
|
||||||
if (header->hb4 & HB4_CD)
|
if (header->hb4 & HB4_CD)
|
||||||
sec_data = 0;
|
sec_data = 0;
|
||||||
|
|||||||
+5
-5
@@ -949,7 +949,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
mess->siaddr = a_record_from_hosts(boot->tftp_sname, now);
|
mess->siaddr = a_record_from_hosts(boot->tftp_sname, now);
|
||||||
|
|
||||||
if (boot->file)
|
if (boot->file)
|
||||||
strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
|
safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
|
||||||
}
|
}
|
||||||
|
|
||||||
option_put(mess, end, OPTION_MESSAGE_TYPE, 1,
|
option_put(mess, end, OPTION_MESSAGE_TYPE, 1,
|
||||||
@@ -2360,7 +2360,7 @@ static void do_options(struct dhcp_context *context,
|
|||||||
in_list(req_options, OPTION_SNAME))
|
in_list(req_options, OPTION_SNAME))
|
||||||
option_put_string(mess, end, OPTION_SNAME, boot->sname, 1);
|
option_put_string(mess, end, OPTION_SNAME, boot->sname, 1);
|
||||||
else
|
else
|
||||||
strncpy((char *)mess->sname, boot->sname, sizeof(mess->sname)-1);
|
safe_strncpy((char *)mess->sname, boot->sname, sizeof(mess->sname));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot->file)
|
if (boot->file)
|
||||||
@@ -2370,7 +2370,7 @@ static void do_options(struct dhcp_context *context,
|
|||||||
in_list(req_options, OPTION_FILENAME))
|
in_list(req_options, OPTION_FILENAME))
|
||||||
option_put_string(mess, end, OPTION_FILENAME, boot->file, 1);
|
option_put_string(mess, end, OPTION_FILENAME, boot->file, 1);
|
||||||
else
|
else
|
||||||
strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
|
safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot->next_server.s_addr)
|
if (boot->next_server.s_addr)
|
||||||
@@ -2387,14 +2387,14 @@ static void do_options(struct dhcp_context *context,
|
|||||||
if ((!req_options || !in_list(req_options, OPTION_FILENAME)) &&
|
if ((!req_options || !in_list(req_options, OPTION_FILENAME)) &&
|
||||||
(opt = option_find2(OPTION_FILENAME)) && !(opt->flags & DHOPT_FORCE))
|
(opt = option_find2(OPTION_FILENAME)) && !(opt->flags & DHOPT_FORCE))
|
||||||
{
|
{
|
||||||
strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file)-1);
|
safe_strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file));
|
||||||
done_file = 1;
|
done_file = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!req_options || !in_list(req_options, OPTION_SNAME)) &&
|
if ((!req_options || !in_list(req_options, OPTION_SNAME)) &&
|
||||||
(opt = option_find2(OPTION_SNAME)) && !(opt->flags & DHOPT_FORCE))
|
(opt = option_find2(OPTION_SNAME)) && !(opt->flags & DHOPT_FORCE))
|
||||||
{
|
{
|
||||||
strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname)-1);
|
safe_strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname));
|
||||||
done_server = 1;
|
done_server = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -234,7 +234,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
safe_strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
||||||
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
||||||
{
|
{
|
||||||
mtu = ifr.ifr_mtu;
|
mtu = ifr.ifr_mtu;
|
||||||
|
|||||||
+11
@@ -283,6 +283,17 @@ void *safe_malloc(size_t size)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure limited size string is always terminated.
|
||||||
|
* Can be replaced by (void)strlcpy() on some platforms */
|
||||||
|
void safe_strncpy(char *dest, const char *src, size_t size)
|
||||||
|
{
|
||||||
|
if (size != 0)
|
||||||
|
{
|
||||||
|
dest[size-1] = '\0';
|
||||||
|
strncpy(dest, src, size-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void safe_pipe(int *fd, int read_noblock)
|
void safe_pipe(int *fd, int read_noblock)
|
||||||
{
|
{
|
||||||
if (pipe(fd) == -1 ||
|
if (pipe(fd) == -1 ||
|
||||||
|
|||||||
Reference in new issue
Block a user