Compare commits

..
24 Commits
Author SHA1 Message Date
pedro 6aee2a45f8 Fix UDP upstream socket bind before connect
Connecting an unbound UDP socket implicitly assigns a local address and
port. A subsequent bind() fails with EINVAL when min-port, max-port or
an explicit source address requires local_bind() to bind the socket.

Bind the local socket and set the outgoing interface before connecting
to the upstream server. Preserve the existing error reporting.

Fixes: cc32bce779 ("connect() UDP sockets to upstream DNS servers to mitigate SAD DNS attack.")
2026-12-04 21:10:15 +00:00
Dickson Wu c936b17bc7 Fix 1-byte OOB read in edns0.c
In edns0.c:482, check_source reads one byte beyond the allocated
packet when a malformed upstream ECS reply reaches the
buffer end under --add-subnet.

Credit to Dickson Wu for the find and the patch.
2026-12-04 21:04:42 +00:00
Simon Kelley 7d58e5dee5 Fix possible infinite loop to dhcpv6 tag-handling.
It was possible for the same --dhcp-vendorclass or --dhcp-userclass option
to match more than once and thus create a loop in the linked-list
used to respresent the set of active tags, and put the code that read that
into an infinite loop.

Code to avoid this was in place, but the check got missed in a couple of
places.

Thanks to Dickson Wu <dickson.wu@certik.com> for spotting this.
2026-12-04 20:51:21 +00:00
Simon Kelley 035eaa22ad Fix OOB read in find SOA - attacker-controlled minTTL
Thanks to 전승훈 <snowjeon2@cau.ac.kr> for finding this bug, it's
a repeat of the problems seen in CVE-2026-4891.

Their explanation:

find_soa() reads two DNS names from an SOA record's RDATA using
extract_name() — the MNAME and RNAME fields. Both calls pass qlen
(the whole-packet bound) rather than a bound derived from the current record's
rdlen. If either name contains a compression pointer or is long enough,
p can be advanced beyond the actual end of the SOA RDATA. The subsequent
length check CHECK_LEN(header, p, qlen, 20) succeeds whenever the advanced
pointer still happens to fall within the overall packet, even if it is now
past the RDATA boundary. The code then executes:

GETLONG(minttl, p); /* reads 4 bytes from the wrong location */ *ttlp = minttl;

The result is that *ttlp is set to 4 bytes read from an arbitrary location inside
the packet rather than the SOA's actual minimum TTL field. A crafted
upstream reply with a DNS-compressed MNAME or RNAME in the SOA RDATA can
therefore cause dnsmasq  to cache any attacker-chosen TTL for negative responses.

Impact

An attacker who controls or can spoof an upstream DNS response can force
dnsmasq to use an arbitrarily large minimum TTL (up to 2³²−1 seconds ≈ 136 years)
for NXDOMAIN caching, effectively poisoning the negative cache and causing
legitimate domains to appear  non-existent to downstream clients indefinitely.
With a TTL of 0 the same attack can disable negative caching entirely.
2026-11-30 21:29:13 +00:00
Simon Kelley 5ef5406a0c Fix possible DNSSEC bypass in prove_non_existence_nsec()
Thanks to 전승훈 <snowjeon2@cau.ac.kr> for finding this bug, it's
a repeat of the problems seen in CVE-2026-4891.

Their explanation:
In prove_non_existence_nsec() around line 1296 of dnssec.c,
the second extract_name() call uses plen as its bound instead of
psave+rdlen. So if a crafted NSEC record has a Next Domain Name
that's longer than rdlen declares, extract_name() happily reads
past the rdata boundary (still within the packet, so no crash), and then
rdlen -= (p - psave) goes negative. The while (rdlen > 0) bitmap loop
never runs, and the function returns 0 as if non-existence was proven,
without ever checking the type bitmap.
2026-11-30 21:13:33 +00:00
Simon Kelley 5ec80aa6c8 Make --conf-file without filename just inhibit reading the default.
This is now consistent with the behaviour of --resolv-file.
2026-11-30 17:04:33 +00:00
Simon Kelley cc32bce779 connect() UDP sockets to upstream DNS servers to mitigate SAD DNS attack.
https://www.saddns.net/

When making a socket to talk to an upstream DNS server via UDP,
call connect() to bind the socket to receiving replies from only that
one server. This mitigates the SAD poisoning attack.

Note that in some circumstances, this will slightly increase resource
use: previously, when forwarding the a query to multiple servers in
parallel, one socket would commonly be used. Now, a socket has to be
created and connect()ed for each server.
2026-11-30 15:46:21 +00:00
sppmasterspp 9e457b1166 Use binary search to find next shorter domain length in lookup_domain()
When a binary search in lookup_domain() misses on a domain of length
old, serverarray[try] points to the last entry sorting before qdomain.
To find the length of the next shorter domain bucket, the existing code
linearly walks serverarray[++try] until domain_len changes.

With large local=/ or address=/ blocklists (e.g. 400k+ entries),
common domain lengths contain 20k-35k entries each, so every non-exact
label lookup linearly scans tens of thousands of scattered struct server
pointers. Multi-label misses (such as search-domain retries like
a.b.c.lan) repeat this scan once per label.

Since serverarray is sorted monotonically non-increasing by domain_len
(order()/order_servers(), with SERV_FOR_NODOTS always having
domain_len == 0 and sorting last), replace the linear walk with a binary
search in O(log N) time. Because qlen strictly decreases on the next
outer iteration and qlen <= old whenever rc > 0, no entry with
domain_len >= old can match any shorter substring, so advancing
low = b_lo when b_lo < daemon->serverarraysz is also safe.

On an ARMv8 router (Asus RT-AX89X, IPQ8074A) with 413k local=/ domains:
- Blocked subdomain (50 queries): 100 ms -> 10 ms (10x faster)
- 4-label .lan suffix retry (50 queries): 300 ms -> 10 ms (30x faster)
- 25 unique uncached forwarded queries (50 queries): 190 ms -> 30 ms
- Live 15s dnsmasq CPU time: 610 ms -> 10 ms

Verified bit-for-bit identical (rc, lowout, highout) against the
original implementation across 503,402 differential test cases covering
SERV_FOR_NODOTS, SERV_WILDCARD, SERV_USE_RESOLV, F_DS, F_DNSSECOK,
F_CONFIG, F_SERVER, F_DOMAINSRV, empty queries, and length gaps.

Assisted-by: Gemini
Tested-by: sppmasterspp <46223847+sppmasterspp@users.noreply.github.com>
Signed-off-by: sppmasterspp <46223847+sppmasterspp@users.noreply.github.com>
2026-11-29 12:45:00 +00:00
Georgi Steffenhagen 34b9f9117f Fix use-after-free in send_ra_alias() for large router advertisements.
send_ra_alias() has the same problem relay_upstream6() had. It keeps
a pointer to the header of the router advertisement while prefixes and
options are added to the packet, and afterwards sets the router
lifetime and the M and O flags through it. If the advertisement
doesn't fit the packet buffer as it is, expand_buf() has moved the
buffer by then. The flags are set in memory which has been freed, and
the advertisement goes out without them, so hosts which see it don't
use DHCPv6.

The buffer starts out at 548 bytes, so this takes an advertisement
larger than that: many prefixes on one interface, or long lists of DNS
servers or search domains. It happens each time an advertisement needs
a larger buffer than any packet before it.

Find the header again each time before writing to it.

Credit to Georgi Steffenhagen (ServerTec IT Engineering) for
finding and fixing this.
2026-11-29 11:51:35 +00:00
Georgi Steffenhagen 9785e2ec41 Fix use-after-free in relay_upstream6(). CVE-2026-133730
relay_upstream6() takes a pointer to the Relay-forward header at the
start of the output packet, then adds the client link-layer address
and relay message options, and then writes the link-address into the
header through that pointer, once for each relay. Adding the options
makes expand_buf() move the packet buffer whenever the relayed message
doesn't fit the buffer as it is, and the buffer starts out at 548
bytes. The link-address is then written into memory which has been
freed, and the packet goes out with an empty link-address.

One DHCPv6 message of about 500 bytes or more arriving on an interface
with --dhcp-relay configured is enough for that. With a normal build
it takes a few messages of growing size to crash dnsmasq: the write
lands on the heap's own bookkeeping in the freed block.

Up to 2.86 the link-address was written before the options were
added. Commit 7fbf1cc ("Improve the performance of DHCP relay.")
moved it into the loop over the relays, so 2.87 is the first release
with the problem.

Find the header again once the packet is complete.

Credit to Akin Yilmaz (DecompilerAI) and, independently,
Georgi Steffenhagen <georgisteffenhagen@servertec.net> for finding this.
2026-11-29 11:37:04 +00:00
Simon Kelley e5731e9928 Silence useless "cannot send packet" warnings. 2026-11-25 20:33:23 +00:00
Simon Kelley 295d546705 Fix race in TCP-process to parent pipe.
The pipe from a TCP handler process to the main dnsmasq process
is used to return information back to the main process, normally
RRsets for caching, but other messages too. This all normally happens
synchronously, but there's one situation where this is not true.

If the TCP handler process last for too long, it is reaped by ALARM
signal, and if the TCP handler process is working on DNSSEC
validation which started in UDP mode, but got promoted to TCP,
then a report of that fact gets sent to the main process so that
the blocked UDP query can be released to fail. By it's nature this
happens asynchronously and if the alarm signal interrupts whilst
another message is being send down the pipe, the two messages get
interleaved and garbage results. If this happens by accident
the usual result to a crash, but it could be manipulated by an
attacker to poison the cache or overwrite random memory.

The fix is to block the alarm signals whilst other processes
are sending messages down the pipe.

Thanks to Daniel Wade for finding and analysing this problem.
2026-11-25 20:00:53 +00:00
Simon Kelley 91a02a187c Remove root key tag 20326 from trust-anchors.
As of 11/11/2026 the root zones are no longer signed with 20326.
The 2024 key, 38696 is now the only valid key.
2026-11-23 18:03:10 +00:00
DL6ER 10fbc39cf5 Return an empty block from blockdata_alloc() for zero length.
738c049 turned the allocation loop in blockdata_alloc_real() from
do/while into for, so a zero length now returns NULL. find_soa() and
extract_addresses() start the chain for an RR with
blockdata_alloc(NULL, 0) and fill it with blockdata_expand(), so they
now fail on every SOA and every RR that is not an address, e.g., MX,
SRV, or SVCB, and those answers are no longer cached. A zero-length
RR also no longer survives cache_recv_insert().

Allocate one empty block for zero length, as before.

Signed-off-by: DL6ER <dl6er@dl6er.de>
2026-11-02 20:46:27 +00:00
Mario Madersbacher 2463798e03 Fix checks on TFTP filenames to avoid directory escape.
Commit d152e81 which fixed escape via pathname of the form "file/.."
introduced a new bug in which pathnames of the form "file/..dir/.."
are not caught.

Note that to be a practical attack, a directory with name
"..somename" has to exist the correct place in the tree.
This seems unlikely on most systems, and a it's difficult to see
how an attacker could create such a directory and not already have
the read access that it gives them.

Thanks to Mario Madersbacher for spotting this, and supplying a very
complete report and patch.
2026-10-26 21:46:00 +00:00
DL6ER a570a139d5 Don't add an empty CNAME alias for a space before a comma.
split() replaces the comma with a space and then writes a NUL over
every space before it, so "a.example ,target.example" becomes
"a.example\0\0target.example". The --cname loop steps over one NUL
and the following spaces only, stops on the second NUL and adds an
empty alias, i.e., a CNAME for the root name. A second such entry is
then rejected as "duplicate CNAME".

Step over the NULs, too.

Signed-off-by: DL6ER <dl6er@dl6er.de>
2026-10-21 22:06:58 +01:00
Simon Kelley 738c049988 Fix OOB heap write in blockdata_read()
A flaw in the blockdata_read() function allows an attacker to overflow
heap buffers. If memory allocation fails whilst reading data from
an IPC pipe, some data is left unread in the pipe. This has the effect of
desynchronising further reads from the pipe and allows an attacker
to overflow a heap buffer.

Note that the attack depends on running the dnsmasq process out of memory
so that calls to malloc() begin to fail. This is difficult to do on
most platforms, unless a small ulimit is set on the size of the
dnsmasq process. This makes practical attacks somewhat difficult.

Thanks to Michel Belleau for finding and characterising this vulnerability.
2026-10-20 23:19:11 +01:00
Simon Kelley 145abca7f6 Fix DNS name buffer overflow.
There are a couple of instances in the DNSSEC validation code where
the code steps along a DNS name to remove some number if left-hand
labels and replace them with * to make a wildcard. The name then
gets passed to to_wire() to translate it in-place to the wire format.

If external parameters dictate that all the labels are removed, and the name
is of exactly the maximum size, then this causes to_wire() to overwrite the
buffer by one byte.

Having created the wildcard, move it to the start of the buffer to avoid
this problem.

Thanks to Lucas Celant <lcelant@redhat.com> for spotting this.

CVE-2026-93011 may apply.
2026-10-20 00:07:34 +01:00
Simon Kelley a627a7847f Fix off-by-one bounds check in DHCPv6 FQDN option.
Thanks to Lucas Celant <lcelant@redhat.com> for spotting this.

CVE-2026-93009 may apply.
2026-10-20 00:07:33 +01:00
Simon Kelley cdbfb97227 Fix logic error in TFTP caching.
The TFTP subsystem prefetches data from disk. If a TFTP transfer
is freed, and a new one allocated the same memory, then previously
prefetched data could be wrongly supplied.

Thanks to Lucas Celant <lcelant@redhat.com> for spotting this.

CVE-2026-93006 may apply.
2026-10-20 00:07:33 +01:00
Simon Kelley 11493fe218 Improve resistance to many simultaneous TCP connections.
Dnsmasq limits the number of simultaneous TCP connections,
to avoid resource-exhaustion attacks. Once the limit if reached,
dnsmasq stops accepting TCP connections from the kernel.

When doing dnssec validation, the same resources are used to
handle internally generated queries with large answers
needed to validate incoming queries which can still arrive via UDP.
If a dnsmasq daemon has reached the limit on incoming
TCP connections then these queries will fail to validate needlessly.

Bump the number of TCP-process resources by 50% when dnssec validation
is enabled, and reserve the extra 50% only for internally-generated
dnssec validation queries. This allows validation to continue even
when dnsmasq is ignoring new TCP requests.

Thanks to Lucas Celant <lcelant@redhat.com> for spotting this.

CVE-2026-93007 may apply.
2026-10-20 00:07:33 +01:00
Simon Kelley 7719737f36 Fix subdomain-test in find_soa()
Do correct subdomain test, rather than a substring match.

Thanks to Lucas Celant <lcelant@redhat.com> for spotting this.

CVE-2026-93008 may apply.
2026-10-20 00:07:33 +01:00
DL6ER 3a3e7a049f Fix the NSEC3 closest encloser check for deeper wildcard answers
`validate_rrset()` returns the start of the closest encloser as an offset
into the owner name, and `prove_non_existence_nsec3()` is meant to stop
its search there. It compares `name - closest_encloser` with that offset,
but `closest_encloser` only moves forward from `name`, so the difference
is never positive and the search never stops at the encloser the RRSIG
labels field gives.

A wildcard answer one label below the closest encloser is not affected,
as the NSEC3 covering the next closer name covers the query name itself.
Two or more labels below, dnsmasq looks for an NSEC3 matching the closest
encloser, which RFC 5155 section 7.2.6 does not require the zone to send,
and returns SERVFAIL with EDE 12 (NSEC Missing). An example is
foo.login.us2.yubico.com, answered from *.us2.yubico.com.

The comparison came with f603a4f ("Fix a corner-case in DNSSEC validation
with wildcards."), which replaced the name compare. Swap the operands.

Signed-off-by: DL6ER <dl6er@dl6er.de>
2026-10-20 00:05:21 +01:00
DL6ER bc80b93cd1 Answer queued TCP queries after a stale answer
When `tcp_request()` answers from stale cache data, it closes the
connection right away, so that the child process can refresh the name
and exit. A query the client has already sent on that connection is
never read, and its answer is lost.

glibc runs into this: after a truncated UDP reply, it sends the A and
AAAA queries together on one TCP connection, gets EOF after the first
answer and fails the lookup without retrying the second query. In a
test with both answers expired, 7 of 20 such lookups lost the second
answer.

Close the connection only if the client has not sent anything else
yet. Otherwise, refresh the name and go on answering the queries on the
connection, as for any other forwarded query.

Signed-off-by: DL6ER <dl6er@dl6er.de>
2026-10-19 23:42:29 +01:00
17 changed files with 283 additions and 121 deletions

No files matched your search

+14
View File
@@ -13,6 +13,20 @@ version 2.94
for spotting and reporting this. A crafted reply can crash dnsmasq.
CNVD-C-2026-590208 applies.
Fix heap OOB write in relay_upstream6() Thanks to
Akin Yilma (DecompilerAI) and Georgi Steffenhagen for spotting this.
CVE-2026-133730 applies. Also fix heap OOB write in send_ra_alias()
which arrises from the same mistake, Credit to
Georgi Steffenhagen (ServerTec IT Engineering) for this one.
Fix possible DNSSEC bypass in prove_non_existence_nsec()
Thanks to 전승훈 Seunghoon Jeon for finding this bug, it's
a repeat of the problems seen in CVE-2026-4891.
Fix OOB read in find SOA - attacker-controlled minTTL
Thanks to 전승훈 Seunghoon Jeon for finding this bug, it's
another repeat of the problems seen in CVE-2026-4891.
version 2.93
Fix a corner-case in DNSSEC validation with wildcards. If we have
+3 -3
View File
@@ -2318,9 +2318,9 @@ Run in a mode where the TFTP server uses ONLY the well-known port (69) for its e
of the TFTP transfer. This allows TFTP to work when there in NAT is the path between client and server. Note that
this is not strictly compliant with the RFCs specifying the TFTP protocol: use at your own risk.
.TP
.B \-C, --conf-file=<file>
Specify a configuration file. The presence of this option stops dnsmasq from reading the default configuration
file (normally /etc/dnsmasq.conf). Multiple files may be specified by repeating the option
.B \-C, --conf-file[=<file>]
Specify a configuration file. The presence of this option (even without a filename) stops dnsmasq from
reading the default configuration file (normally /etc/dnsmasq.conf). Multiple files may be specified by repeating the option
either on the command line or in configuration files. A
filename of "-" causes dnsmasq to read configuration from stdin.
.TP
+50 -21
View File
@@ -16,7 +16,9 @@
#include "dnsmasq.h"
static struct blockdata *keyblock_free;
static struct blockdata *new_block(void);
static struct blockdata *keyblock_free, *fallback;
static unsigned int blockdata_count, blockdata_hwm, blockdata_alloced;
static void add_blocks(int n)
@@ -48,7 +50,11 @@ void blockdata_init(void)
/* Note that daemon->cachesize is enforced to have non-zero size if OPT_DNSSEC_VALID is set */
if (option_bool(OPT_DNSSEC_VALID))
add_blocks(daemon->cachesize);
}
/* make sure we have one block to fall back on. */
if (!(fallback = new_block()))
die(_("Blockdata init: no memory"), NULL, EC_MISC);
}
void blockdata_report(void)
{
@@ -84,35 +90,51 @@ static struct blockdata *blockdata_alloc_real(int fd, char *data, size_t len)
struct blockdata *block, *ret = NULL;
struct blockdata **prev = &ret;
size_t blen;
int fail;
do
/* Zero length still gives one empty block, blockdata_alloc(NULL, 0)
is how callers start a chain to add to with blockdata_expand(). */
if (len == 0)
return new_block();
for (fail = 0; len != 0; len -= blen)
{
if (!(block = new_block()))
{
/* failed to alloc, free partial chain */
blockdata_free(ret);
return NULL;
}
blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len;
if ((blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len) > 0)
if (!fail)
{
if (data)
if ((block = new_block()))
{
memcpy(block->key, data, blen);
data += blen;
*prev = block;
prev = &block->next;
}
else if (!read_write(fd, block->key, blen, RW_READ))
else
{
/* failed read free partial chain */
blockdata_free(ret);
return NULL;
/* Failed to alloc, use the pre-allocated fall-back.
This allows us to always read the specified amount of data from the fd. */
fail = 1;
block = fallback;
}
}
len -= blen;
*prev = block;
prev = &block->next;
} while (len != 0);
if (data)
{
memcpy(block->key, data, blen);
data += blen;
}
else if (!read_write(fd, block->key, blen, RW_READ))
{
fail = 1;
break;
}
}
if (fail)
{
/* failed, free partial chain */
blockdata_free(ret);
return NULL;
}
return ret;
}
@@ -235,6 +257,13 @@ void blockdata_write(struct blockdata *block, size_t len, int fd)
}
}
/* NOTE: this can fail (NULL return) for two possible reasons.
1) end of stream.
2) malloc failure when allocating blocks.
Unless EOF is encountered, len octets will always be read from the stream,
even in memory allocation fails.
*/
struct blockdata *blockdata_read(int fd, size_t len)
{
return blockdata_alloc_real(fd, NULL, len);
+14 -3
View File
@@ -872,6 +872,7 @@ void cache_end_insert(void)
if (daemon->pipe_to_parent != -1)
{
unsigned char op = PIPE_OP_INSERT;
pipe_hold_alarm(1);
read_write(daemon->pipe_to_parent, &op, sizeof(op), RW_WRITE);
}
@@ -935,6 +936,7 @@ void cache_end_insert(void)
{
ssize_t m = -1;
read_write(daemon->pipe_to_parent, (unsigned char *)&m, sizeof(m), RW_WRITE);
pipe_hold_alarm(0);
}
}
@@ -1039,9 +1041,18 @@ int cache_recv_insert(time_t now, int fd)
unsigned short class = C_IN;
struct blockdata *block = NULL;
if ((flags & F_RR) && !(flags & F_NEG) && (flags & F_KEYTAG)
&& !(block = addr.rrblock.rrdata = blockdata_read(fd, addr.rrblock.datalen)))
continue;
/* Note that blockdata_read() can return NULL either
because the stream ended, OR memory allocation failed.
We continue here rather than returning 0 to finish draining
the pipe in the second case. If the stream ended, the read
of the next length at the top of the loop will fail
and we'll return 0 there. */
if (flags & F_RR)
{
if (!(flags & F_NEG) && (flags & F_KEYTAG) &&
!(block = addr.rrblock.rrdata = blockdata_read(fd, addr.rrblock.datalen)))
continue;
}
#ifdef HAVE_DNSSEC
else if (flags & F_DNSKEY)
{
+44 -10
View File
@@ -140,6 +140,9 @@ int main (int argc, char **argv)
/* one char flag per possible RR in answer section (may get extended). */
daemon->rr_status_sz = 64;
daemon->rr_status = safe_malloc(sizeof(*daemon->rr_status) * daemon->rr_status_sz);
/* Increase TCP process slots by half, and reserve the extra for validation-to-tcp use only. */
daemon->dnssec_tcp_slot_reserved = daemon->max_procs/2;
daemon->max_procs += daemon->dnssec_tcp_slot_reserved;
}
#endif
@@ -427,6 +430,7 @@ int main (int argc, char **argv)
daemon->tcp_pids = safe_malloc(daemon->max_procs*sizeof(pid_t));
daemon->tcp_pipes = safe_malloc(daemon->max_procs*sizeof(int));
daemon->tcp_type = safe_malloc(daemon->max_procs);
for (i = 0; i < daemon->max_procs; i++)
daemon->tcp_pipes[i] = -1;
@@ -1364,7 +1368,7 @@ static void sig_handler(int sig)
else
{
/* udp_to_tcp transfer.
If daemon->header_to_tcp is NULL the waiting is over and
If daemon->header_to_tcp is NULL we're in debug mode and
we can let things take their course, otherwise, send a failure
return down the pipe to unblock the UDP transaction and kill
the process. */
@@ -1433,6 +1437,17 @@ void send_alarm(time_t event, time_t now)
}
}
/* Don't let the alarm handler interleave messages on the parent pipe. */
void pipe_hold_alarm(int hold)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(hold ? SIG_BLOCK : SIG_UNBLOCK, &set, NULL);
}
void queue_event(int event)
{
send_event(pipewrite, event, 0, NULL);
@@ -1652,7 +1667,11 @@ static void async_event(int pipe, time_t now)
/* tcp_pipes == -1 && tcp_pids == 0 required to free slot */
if (daemon->tcp_pipes[i] == -1)
daemon->metrics[METRIC_TCP_CONNECTIONS]--;
{
if (daemon->tcp_type[i])
daemon->dnssec_tcp_slot_reserved++;
daemon->metrics[METRIC_TCP_CONNECTIONS]--;
}
}
break;
@@ -1888,7 +1907,7 @@ static void set_dns_listeners(void)
struct serverfd *serverfdp;
struct listener *listener;
struct randfd_list *rfl;
int i;
int i, j;
for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
poll_listen(serverfdp->fd, POLLIN);
@@ -1902,8 +1921,8 @@ static void set_dns_listeners(void)
poll_listen(rfl->rfd->fd, POLLIN);
/* check to see if we have free tcp process slots. */
for (i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
for (j = 0, i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1 && ++j > daemon->dnssec_tcp_slot_reserved)
break;
for (listener = daemon->listeners; listener; listener = listener->next)
@@ -1930,7 +1949,7 @@ static void check_dns_listeners(time_t now)
struct serverfd *serverfdp;
struct listener *listener;
struct randfd_list *rfl;
int i;
int i, j;
/* Note that handling events here can create or destroy fds and
render the result of the last poll() call invalid. Once
@@ -1955,7 +1974,11 @@ static void check_dns_listeners(time_t now)
daemon->tcp_pipes[i] = -1;
/* tcp_pipes == -1 && tcp_pids == 0 required to free slot */
if (daemon->tcp_pids[i] == 0)
daemon->metrics[METRIC_TCP_CONNECTIONS]--;
{
daemon->metrics[METRIC_TCP_CONNECTIONS]--;
if (daemon->tcp_type[i])
daemon->dnssec_tcp_slot_reserved++;
}
}
return;
}
@@ -1995,8 +2018,8 @@ static void check_dns_listeners(time_t now)
at least one a poll() time, that we still do.
There may be more waiting connections after
poll() returns then free process slots. */
for (i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1)
for (j = 0,i = daemon->max_procs - 1; i >= 0; i--)
if (daemon->tcp_pids[i] == 0 && daemon->tcp_pipes[i] == -1 && ++j > daemon->dnssec_tcp_slot_reserved)
break;
if (i >= 0)
@@ -2165,6 +2188,7 @@ static void do_tcp_connection(struct listener *listener, time_t now, int slot)
daemon->tcp_pids[slot] = p;
daemon->tcp_pipes[slot] = pipefd[0];
daemon->tcp_type[slot] = 0;
daemon->metrics[METRIC_TCP_CONNECTIONS]++;
if (daemon->metrics[METRIC_TCP_CONNECTIONS] > daemon->max_procs_used)
daemon->max_procs_used = daemon->metrics[METRIC_TCP_CONNECTIONS];
@@ -2239,7 +2263,9 @@ static void do_tcp_connection(struct listener *listener, time_t now, int slot)
if (!option_bool(OPT_DEBUG))
{
#ifdef HAVE_DNSSEC
pipe_hold_alarm(1);
cache_update_hwm(); /* Sneak out possibly updated crypto HWM values. */
pipe_hold_alarm(0);
#endif
close(daemon->pipe_to_parent);
@@ -2306,6 +2332,8 @@ int swap_to_tcp(struct frec *forward, time_t now, int status, struct dns_header
/* i holds index of free slot */
daemon->tcp_pids[i] = p;
daemon->tcp_pipes[i] = pipefd[0];
daemon->tcp_type[i] = 1;
daemon->dnssec_tcp_slot_reserved--;
daemon->metrics[METRIC_TCP_CONNECTIONS]++;
if (daemon->metrics[METRIC_TCP_CONNECTIONS] > daemon->max_procs_used)
daemon->max_procs_used = daemon->metrics[METRIC_TCP_CONNECTIONS];
@@ -2372,6 +2400,8 @@ int swap_to_tcp(struct frec *forward, time_t now, int status, struct dns_header
{
unsigned char op = PIPE_OP_RESULT;
pipe_hold_alarm(1); /* Released below, once the pipe is closed. */
/* tell our parent we're done, and what the result was then exit. */
read_write(daemon->pipe_to_parent, &op, sizeof(op), RW_WRITE);
read_write(daemon->pipe_to_parent, (unsigned char *)&status, sizeof(status), RW_WRITE);
@@ -2387,7 +2417,11 @@ int swap_to_tcp(struct frec *forward, time_t now, int status, struct dns_header
cache_update_hwm(); /* Sneak out possibly updated crypto HWM values. */
close(daemon->pipe_to_parent);
/* Nothing more goes up the pipe. Let the alarm in again, so a log
socket that never drains can't hold us in flush_log() for ever.
With forward_to_tcp clear, the handler just exits. */
daemon->forward_to_tcp = NULL;
pipe_hold_alarm(0);
flush_log();
_exit(0);
}
+3 -1
View File
@@ -1296,6 +1296,7 @@ extern struct daemon {
int fd_save; /* " " */
pid_t *tcp_pids;
int *tcp_pipes;
char *tcp_type;
int pipe_to_parent;
int numrrand;
struct randfd *randomsocks;
@@ -1355,7 +1356,7 @@ extern struct daemon {
/* file for packet dumps. */
int dumpfd;
#endif
int max_procs;
int max_procs, dnssec_tcp_slot_reserved;
uint max_procs_used;
} *daemon;
@@ -1383,6 +1384,7 @@ void cache_end_insert(void);
void cache_start_insert(void);
unsigned int cache_remove_uid(const unsigned int uid);
int cache_recv_insert(time_t now, int fd);
void pipe_hold_alarm(int hold);
#ifdef HAVE_DNSSEC
void cache_update_hwm(void);
#endif
+14 -9
View File
@@ -486,7 +486,6 @@ static int validate_rrset(time_t now, struct dns_header *header, size_t plen, in
int i, wire_len, sig_len;
const struct nettle_hash *hash;
void *ctx;
char *name_start;
u32 nsigttl, ttl, orig_ttl;
failflags &= ~DNSSEC_FAIL_NOSIG;
@@ -576,13 +575,13 @@ static int validate_rrset(time_t now, struct dns_header *header, size_t plen, in
if (!extract_name(header, plen, &p, name, EXTR_NAME_EXTRACT, 10))
return STAT_BOGUS;
name_start = name;
/* if more labels than in RRsig name, hash *.<no labels in rrsig labels field> 4035 5.3.2 */
/* If the name is already the wildcard, we're not going to change it. */
if (labels < name_labels &&
!(name_labels - labels == 1 && name_start[0] == '*' && name_start[1] == '.'))
!(name_labels - labels == 1 && name[0] == '*' && name[1] == '.'))
{
char *name_start = name;
for (j = name_labels - labels; j != 0; j--)
{
while (*name_start != '.' && *name_start != 0)
@@ -596,10 +595,12 @@ static int validate_rrset(time_t now, struct dns_header *header, size_t plen, in
name_start--;
*name_start = '*';
/* move our name to the start of the buffer to avoid pathalogical cases over-running the end in to_wire(). */
memmove(name, name_start, strlen(name_start) + 1);
}
wire_len = to_wire(name_start);
hash->update(ctx, (unsigned int)wire_len, (unsigned char *)name_start);
wire_len = to_wire(name);
hash->update(ctx, (unsigned int)wire_len, (unsigned char *)name);
hash->update(ctx, 4, p); /* class and type */
hash->update(ctx, 4, (unsigned char *)&nsigttl);
@@ -1291,7 +1292,9 @@ static int prove_non_existence_nsec(struct dns_header *header, size_t plen, unsi
GETSHORT(rdlen, p);
psave = p;
if (!extract_name(header, plen, &p, workspace2, EXTR_NAME_EXTRACT, 0))
/* If the name is longer that rdlen, then our bitmap code gets
very confused. Doing that deliberately can bypass type bitmap checks. */
if (!extract_name(header, plen, &p, workspace2, EXTR_NAME_EXTRACT, 0) || (p - psave > rdlen))
return DNSSEC_FAIL_BADPACKET;
/* If NSEC comes from wildcard expansion, use original wildcard
@@ -1643,7 +1646,7 @@ static int prove_non_existence_nsec3(struct dns_header *header, size_t plen, uns
if (*closest_encloser == '.')
closest_encloser++;
if (wild_offset != 0 && name - closest_encloser == wild_offset)
if (wild_offset != 0 && closest_encloser - name == wild_offset)
break;
if (dec_counter(validate_counter, NULL))
@@ -1694,11 +1697,13 @@ static int prove_non_existence_nsec3(struct dns_header *header, size_t plen, uns
wildcard--;
*wildcard = '*';
/* move our name to the start of the buffer to avoid pathalogical cases over-running the end in to_wire(). */
memmove(name, wildcard, strlen(wildcard) + 1);
if (dec_counter(validate_counter, NULL))
return DNSSEC_FAIL_WORK;
if ((digest_len = hash_name(wildcard, &digest, hash, salt, salt_len, iterations)) == 0)
if ((digest_len = hash_name(name, &digest, hash, salt, salt_len, iterations)) == 0)
return DNSSEC_FAIL_NONSEC;
if (!check_nsec3_coverage(header, plen, digest_len, digest, type, workspace1, workspace2, nsecs, nsec_count, NULL, 1))
+18 -8
View File
@@ -177,20 +177,30 @@ int lookup_domain(char *domain, int flags, int *lowout, int *highout)
try+1 is not optimal, consider searching bbb in (aaa,ccc,bb). try will point
to aaa, since ccc sorts after bbb, but the first domain that has a chance to
match is bb. So find the length of the first domain later than try which is
is shorter than it.
is shorter than it. Because the domains are sorted first by length, we can
use a binary search here: On long blocklists, there will be thousands of
names with the same length, so a linear search though those blocks would
be slow.
There's a nasty edge case when qdomain sorts before _any_ of the
server domains, where try _doesn't point_ to the last domain that sorts
before the query, since no such domain exists. In that case, the loop
exits via the rc < 0 && high == try path above and this code is
not executed. */
ssize_t len, old = daemon->serverarray[try]->domain_len;
while (++try != daemon->serverarraysz)
size_t old = daemon->serverarray[try]->domain_len;
int b_lo = try + 1, b_hi = daemon->serverarraysz, mid;
while (b_lo < b_hi)
{
if (old != (len = daemon->serverarray[try]->domain_len))
{
crop_query = qlen - len;
break;
}
mid = b_lo + (b_hi - b_lo) / 2;
if (daemon->serverarray[mid]->domain_len == old)
b_lo = mid + 1;
else
b_hi = mid;
}
if (b_lo != daemon->serverarraysz)
{
crop_query = qlen - daemon->serverarray[b_lo]->domain_len;
low = b_lo;
}
break;
}
+6 -3
View File
@@ -478,12 +478,15 @@ int check_source(struct dns_header *header, size_t plen, unsigned char *pseudohe
{
if (peer)
{
/* make sure this doesn't mismatch. */
/* make sure this doesn't mismatch. Check the length first: an option
shorter than 4 bytes has no scope_netmask byte to read. */
if (len != calc_len)
return 0;
opt.scope_netmask = p[3];
if (len != calc_len || memcmp(p, &opt, len) != 0)
if (memcmp(p, &opt, len) != 0)
return 0;
}
else if (((struct subnet_opt *)p)->source_netmask != 0)
else if (len >= 3 && ((struct subnet_opt *)p)->source_netmask != 0)
return 0;
}
p += len;
+56 -32
View File
@@ -98,8 +98,10 @@ int send_from(int fd, int nowild, char *packet, size_t len,
if (errno != 0)
{
#ifdef HAVE_LINUX_NETWORK
/* If interface is still in DAD, EINVAL results - ignore that. */
if (errno != EINVAL)
/* If interface is still in DAD, EINVAL results - ignore that.
Sending an IPv6 packet via an interface with only deprecated address(es)
results in EACCESS, ignore that too. */
if (errno != EINVAL && errno != EACCES)
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
#endif
return 0;
@@ -134,14 +136,6 @@ static void log_query_mysockaddr(unsigned int flags, char *name, union mysockadd
}
}
static void server_send(struct server *server, int fd,
const void *header, size_t plen)
{
while (retry_send(sendto(fd, header, plen, 0,
&server->addr.sa,
sa_len(&server->addr))));
}
static int domain_no_rebind(char *domain)
{
struct rebind_domain *rbd;
@@ -533,9 +527,8 @@ static void forward_query(int udpfd, union mysockaddr *udpaddr,
if (option_bool(OPT_CONNTRACK))
set_outgoing_mark(forward, fd);
#endif
if (retry_send(sendto(fd, (char *)header, plen, 0,
&srv->addr.sa,
sa_len(&srv->addr))))
/* fd is connect()ed by random_sock) */
if (retry_send(send(fd, (char *)header, plen, 0)))
continue;
if (errno == 0)
@@ -1092,7 +1085,7 @@ static void dnssec_validate(struct frec *forward, struct dns_header *header,
set_outgoing_mark(orig, fd);
#endif
server_send(server, fd, header, nn);
while(retry_send(send(fd, (char *)header, nn, 0)));
server->queries++;
#ifdef HAVE_DUMPFILE
dump_packet_udp(DUMP_SEC_QUERY, (void *)header, (size_t)nn, NULL, &server->addr, fd);
@@ -2406,7 +2399,7 @@ void tcp_request(int confd, time_t now, struct iovec *bigbuff,
unsigned char *pheader;
unsigned int mark = 0;
int have_mark = 0;
int first, last, filtered, do_stale = 0;
int first, last, filtered, do_stale = 0, closed = 0;
struct iovec out_iov[2];
bigbuff->iov_base = NULL;
@@ -2742,8 +2735,16 @@ void tcp_request(int confd, time_t now, struct iovec *bigbuff,
}
}
/* Fresh data is in the cache now. Go on with the queries the client
had already sent, if the connection is still open. */
if (do_stale)
break;
{
if (closed)
break;
do_stale = 0;
daemon->log_source_addr = &peer_addr;
continue;
}
/* In case of local answer or no connections made. */
if (m == 0)
@@ -2792,19 +2793,27 @@ void tcp_request(int confd, time_t now, struct iovec *bigbuff,
/* If we answered with stale data, this process will now try and get fresh data into
the cache and cannot therefore accept new queries. Close the incoming
connection to signal that to the client. Then set do_stale and loop round
once more to try and get fresh data, after which we exit. */
once more to try and get fresh data, after which we exit. A client which
has already sent its next query is waiting for the answer and would lose
it, so keep the connection open then and answer it after the refresh. */
if (stale)
{
shutdown(confd, SHUT_RDWR);
close(confd);
char c;
if (recv(confd, &c, 1, MSG_PEEK | MSG_DONTWAIT) != 1)
{
shutdown(confd, SHUT_RDWR);
close(confd);
closed = 1;
}
do_stale = 1;
/* Don't mark the query with the source when refreshing stale data. */
daemon->log_source_addr = NULL;
}
}
/* If we ran once to get fresh data, confd is already closed. */
if (!do_stale)
/* If we ran once to get fresh data, confd may be closed already. */
if (!closed)
{
shutdown(confd, SHUT_RDWR);
close(confd);
@@ -2821,6 +2830,8 @@ static int random_sock(struct server *s)
if ((fd = socket(s->source_addr.sa.sa_family, SOCK_DGRAM, 0)) != -1)
{
int connecterr = 0;
/* We need to set IPV6ONLY so we can use the same ports
for IPv4 and IPV6, otherwise, in restriced port situations,
we can end up with all our available ports in use for
@@ -2837,18 +2848,31 @@ static int random_sock(struct server *s)
}
if (local_bind(fd, &s->source_addr, s->interface, s->ifindex, 0))
return fd;
{
if (connect(fd, &s->addr.sa, sa_len(&s->addr)) == -1)
connecterr = 1;
else
return fd;
}
/* don't log errors due to running out of available ports, we handle those. */
if (!sockaddr_isnull(&s->source_addr) || errno != EADDRINUSE)
if (connecterr || !sockaddr_isnull(&s->source_addr) || errno != EADDRINUSE)
{
if (s->interface[0] == 0)
char *mess;
if (connecterr)
mess = _("failed to connect server socket to %s: %s");
else
mess = _("failed to bind server socket to %s: %s");
if (connecterr)
(void)prettyprint_addr(&s->addr, daemon->addrbuff);
else if (s->interface[0] == 0)
(void)prettyprint_addr(&s->source_addr, daemon->addrbuff);
else
safe_strncpy(daemon->addrbuff, s->interface, ADDRSTRLEN);
my_syslog(LOG_ERR, _("failed to bind server socket to %s: %s"),
daemon->addrbuff, strerror(errno));
my_syslog(LOG_ERR, mess, daemon->addrbuff, strerror(errno));
}
close(fd);
@@ -2857,14 +2881,15 @@ static int random_sock(struct server *s)
return -1;
}
/* compare source addresses and interface, serv2 can be null. */
/* compare source/dest addresses and interface, serv2 can be null. */
static int server_isequal(const struct server *serv1,
const struct server *serv2)
{
return (serv2 &&
serv2->ifindex == serv1->ifindex &&
sockaddr_isequal(&serv2->source_addr, &serv1->source_addr) &&
strncmp(serv2->interface, serv1->interface, IF_NAMESIZE) == 0);
serv2->ifindex == serv1->ifindex &&
sockaddr_isequal(&serv2->source_addr, &serv1->source_addr) &&
sockaddr_isequal(&serv2->addr, &serv1->addr) &&
strncmp(serv2->interface, serv1->interface, IF_NAMESIZE) == 0);
}
/* fdlp points to chain of randomfds already in use by transaction.
@@ -3310,8 +3335,7 @@ static struct frec *lookup_frec(time_t now, char *target, int class, int rrtype,
void resend_query(void)
{
if (daemon->srv_save)
server_send(daemon->srv_save, daemon->fd_save,
daemon->packet, daemon->packet_len);
while(retry_send(send(daemon->fd_save, (char *)daemon->packet, daemon->packet_len, 0)));
}
/* A server record is going away, remove references to it */
+1 -2
View File
@@ -41,8 +41,7 @@ void loop_send_probes(void)
if ((fd = allocate_rfd(&rfds, serv)) == -1)
continue;
while (retry_send(sendto(fd, daemon->packet, len, 0,
&serv->addr.sa, sa_len(&serv->addr))));
while (retry_send(send(fd, daemon->packet, len, 0)));
}
free_rfds(&rfds);
+13 -16
View File
@@ -424,7 +424,7 @@ static struct {
{ 'b', OPT_BOGUSPRIV, NULL, gettext_noop("Fake reverse lookups for RFC1918 private address ranges."), NULL },
{ 'B', ARG_DUP, "<ipaddr>", gettext_noop("Treat ipaddr as NXDOMAIN (defeats Verisign wildcard)."), NULL },
{ 'c', ARG_ONE, "<integer>", gettext_noop("Specify the size of the cache in entries (defaults to %s)."), "$" },
{ 'C', ARG_DUP, "<path>", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE },
{ 'C', ARG_DUP, "[<path>]", gettext_noop("Specify configuration file (defaults to %s)."), CONFFILE },
{ 'd', OPT_DEBUG, NULL, gettext_noop("Do NOT fork into the background: run in debug mode."), NULL },
{ 'D', OPT_NODOTS_LOCAL, NULL, gettext_noop("Do NOT forward queries with no domain part."), NULL },
{ 'e', OPT_SELFMX, NULL, gettext_noop("Return self-pointing MX records for local hosts."), NULL },
@@ -5046,7 +5046,7 @@ err:
new->target = target;
new->ttl = ttl;
for (arg += arglen+1; *arg && isspace((unsigned char)*arg); arg++);
for (arg += arglen+1; arg != last && (!*arg || isspace((unsigned char)*arg)); arg++);
}
break;
@@ -5985,8 +5985,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
{
size_t argbuf_size = 300;
char *argbuf = safe_malloc(argbuf_size);
int option, testmode = 0;
char *arg, *conffile = NULL;
int option, testmode = 0, conf_read = 0;
char *arg;
opterr = 0;
@@ -6095,13 +6095,15 @@ void read_opts(int argc, char **argv, char *compile_opts)
}
else if (option == 'C')
{
if (!conffile)
conffile = opt_string_alloc(arg);
else
char *conffile = opt_string_alloc(arg);
/* Inhibit /etc/dnsmasq.conf even if no file given */
conf_read = 1;
if (conffile)
{
char *extra = opt_string_alloc(arg);
one_file(extra, 0);
free(extra);
one_file(conffile, 0);
free(conffile);
}
}
else
@@ -6117,12 +6119,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
free(argbuf);
if (conffile)
{
one_file(conffile, 0);
free(conffile);
}
else
if (!conf_read)
one_file(CONFFILE, LOPT_CONF_OPT);
/* Add TXT records if wanted */
+7
View File
@@ -400,6 +400,10 @@ static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_ad
up = &context->next;
}
/* Adding the prefixes above may have moved the packet buffer,
so find the header again before writing to it. */
ra = daemon->outpacket.iov_base;
/* If we're advertising only old prefixes, set router lifetime to zero. */
if (old_prefix && !parm.found_context)
ra->lifetime = htons(0);
@@ -531,6 +535,9 @@ static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_ad
put_opt6(&parm.link_local, IN6ADDRSZ);
}
/* The options added since then may have moved the buffer again. */
ra = daemon->outpacket.iov_base;
/* set managed bits unless we're providing only RA on this link */
if (parm.managed)
ra->flags |= 0x80; /* M flag, managed, */
+13 -4
View File
@@ -560,7 +560,7 @@ static int find_soa(struct dns_header *header, size_t qlen, char *name, int *sub
soa_len = strlen(daemon->workspacename);
/* SOA must be for the name we're interested in. */
if (soa_len <= name_len && memcmp(daemon->workspacename, name + name_len - soa_len, soa_len) == 0)
if (hostname_issubdomain(daemon->workspacename, name) != 0)
{
int prefix = name_len - soa_len;
@@ -574,7 +574,8 @@ static int find_soa(struct dns_header *header, size_t qlen, char *name, int *sub
for (j = 0; j < 2; j++) /* MNAME, RNAME */
{
if (!extract_name(header, qlen, &p, daemon->workspacename, EXTR_NAME_EXTRACT, 0))
if (!extract_name(header, qlen, &p, daemon->workspacename, EXTR_NAME_EXTRACT, 0) ||
(p - psave > rdlen))
{
if (cache)
blockdata_free(addr.rrblock.rrdata);
@@ -1007,7 +1008,11 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
if (ipsets)
{
if (daemon->pipe_to_parent != -1)
cache_send_ipset(PIPE_OP_IPSET, ipsets, flags, &addr);
{
pipe_hold_alarm(1);
cache_send_ipset(PIPE_OP_IPSET, ipsets, flags, &addr);
pipe_hold_alarm(0);
}
else
for (ipsets_cur = ipsets->sets; *ipsets_cur; ipsets_cur++)
if (add_to_ipset(*ipsets_cur, &addr, flags, 0) == 0)
@@ -1018,7 +1023,11 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
if (nftsets)
{
if (daemon->pipe_to_parent != -1)
cache_send_ipset(PIPE_OP_NFTSET, nftsets, flags, &addr);
{
pipe_hold_alarm(1);
cache_send_ipset(PIPE_OP_NFTSET, nftsets, flags, &addr);
pipe_hold_alarm(0);
}
else
for (nftsets_cur = nftsets->sets; *nftsets_cur; nftsets_cur++)
if (add_to_nftset(*nftsets_cur, &addr, flags, 0) == 0)
+10 -4
View File
@@ -224,7 +224,7 @@ static int dhcp6_maybe_relay(struct state *state, unsigned char *inbuff, size_t
if ((opt = opt6_find(opts, end, mopt, 1)) &&
vendor->len == opt6_len(opt) &&
memcmp(vendor->data, opt6_ptr(opt, 0), vendor->len) == 0 &&
vendor->netid.next != &vendor->netid)
vendor->netid.next == &vendor->netid)
{
vendor->netid.next = state->tags;
state->tags = &vendor->netid;
@@ -399,7 +399,8 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
continue;
/* matching enterprise, no string match. */
if (vendor->enterprise != 0 && vendor->len == 0)
if (vendor->enterprise != 0 && vendor->len == 0 &&
vendor->netid.next == &vendor->netid)
{
vendor->netid.next = state->tags;
state->tags = &vendor->netid;
@@ -418,7 +419,8 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
for (enc_opt = opt6_user_vendor_first(opt6_ptr(opt, offset), enc_end);
enc_opt; enc_opt = opt6_user_vendor_next(enc_opt, enc_end))
for (i = 0; i <= (opt6_user_vendor_len(enc_opt) - vendor->len); i++)
if (memcmp(vendor->data, opt6_user_vendor_ptr(enc_opt, i), vendor->len) == 0)
if (memcmp(vendor->data, opt6_user_vendor_ptr(enc_opt, i), vendor->len) == 0 &&
vendor->netid.next == &vendor->netid)
{
vendor->netid.next = state->tags;
state->tags = &vendor->netid;
@@ -502,7 +504,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
state->fqdn_flags &= ~0x04;
if (len != 0 && len < 255)
if (len >= 1 && len < 255)
{
unsigned char *pp, *op = opt6_ptr(opt, 1);
char *pq = daemon->dhcp_buff;
@@ -2218,6 +2220,10 @@ int relay_upstream6(int iface_index, ssize_t sz,
put_opt6(inbuff, sz);
end_opt6(o);
/* Adding the options above may have moved the packet buffer,
so find the header again before writing to it below. */
header = daemon->outpacket.iov_base;
for (; relay; relay = relay->next)
if (relay->iface_index != 0 && relay->iface_index == iface_index)
{
+16 -3
View File
@@ -545,10 +545,17 @@ static struct tftp_file *check_tftp_fileperm(char *packet, ssize_t *len, char *p
/* trick to ban moving out of the subtree */
if (prefix)
{
char *suspect = strstr(namebuff, "/..");
char *suspect = namebuff;
if (suspect && (suspect[3] == '/' || suspect[3] == 0))
goto perm;
/* Every occurrence has to be checked: a harmless leading match
such as "/..data" otherwise hides a later "/../" from here. */
while ((suspect = strstr(suspect, "/..")))
{
if (suspect[3] == '/' || suspect[3] == 0)
goto perm;
suspect += 3;
}
}
if ((fd = open(namebuff, O_RDONLY)) == -1)
@@ -837,6 +844,12 @@ static void free_transfer(struct tftp_transfer *transfer)
free(transfer->file);
}
/* freeing this transfer and then allocating a new one
may result in the same memory, but the contents of
the transfer is no longer valid to cache. */
if (daemon->srv_save == transfer)
daemon->srv_save = NULL;
free(transfer);
}
+1 -2
View File
@@ -1,9 +1,8 @@
# The root DNSSEC trust anchor, valid as at 18/07/2024
# The root DNSSEC trust anchor, valid as at 11/11/2026
# Note that this is a DS record (i.e. a hash of the root Zone Signing Key)
# It was downloaded from https://data.iana.org/root-anchors/root-anchors.xml
trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D
trust-anchor=.,38696,8,2,683D2D0ACB8C9B712A1948B27F741219298D0A450D612C483AF444A4C0FB2B16