mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-12-05 22:18:35 +00:00
Compare commits
24
Commits
03fd0c19ef
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6aee2a45f8 | ||
|
|
c936b17bc7 | ||
|
|
7d58e5dee5 | ||
|
|
035eaa22ad | ||
|
|
5ef5406a0c | ||
|
|
5ec80aa6c8 | ||
|
|
cc32bce779 | ||
|
|
9e457b1166 | ||
|
|
34b9f9117f | ||
|
|
9785e2ec41 | ||
|
|
e5731e9928 | ||
|
|
295d546705 | ||
|
|
91a02a187c | ||
|
|
10fbc39cf5 | ||
|
|
2463798e03 | ||
|
|
a570a139d5 | ||
|
|
738c049988 | ||
|
|
145abca7f6 | ||
|
|
a627a7847f | ||
|
|
cdbfb97227 | ||
|
|
11493fe218 | ||
|
|
7719737f36 | ||
|
|
3a3e7a049f | ||
|
|
bc80b93cd1 |
No files matched your search
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 */
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user