"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/rfc1035.c" between
dnsmasq-2.84.tar.xz and dnsmasq-2.85.tar.xz

About: Dnsmasq is a lightweight caching DNS forwarder and DHCP server.

rfc1035.c  (dnsmasq-2.84.tar.xz):rfc1035.c  (dnsmasq-2.85.tar.xz)
skipping to change at line 1019 skipping to change at line 1019
for (ptr = daemon->ptr; ptr; ptr = ptr->next) for (ptr = daemon->ptr; ptr; ptr = ptr->next)
if (hostname_issubdomain(name, ptr->name)) if (hostname_issubdomain(name, ptr->name))
return 1; return 1;
if (cache_find_non_terminal(name, now)) if (cache_find_non_terminal(name, now))
return 1; return 1;
return 0; return 0;
} }
/* Is the packet a reply with the answer address equal to addr? static int check_bad_address(struct dns_header *header, size_t qlen, struct bogu
If so mung is into an NXDOMAIN reply and also put that information s_addr *baddr, char *name, unsigned long *ttlp)
in the cache. */
int check_for_bogus_wildcard(struct dns_header *header, size_t qlen, char *name,
struct bogus_addr *baddr, time_t now)
{ {
unsigned char *p; unsigned char *p;
int i, qtype, qclass, rdlen; int i, qtype, qclass, rdlen;
unsigned long ttl; unsigned long ttl;
struct bogus_addr *baddrp; struct bogus_addr *baddrp;
struct in_addr addr;
/* skip over questions */ /* skip over questions */
if (!(p = skip_questions(header, qlen))) if (!(p = skip_questions(header, qlen)))
return 0; /* bad packet */ return 0; /* bad packet */
for (i = ntohs(header->ancount); i != 0; i--) for (i = ntohs(header->ancount); i != 0; i--)
{ {
if (!extract_name(header, qlen, &p, name, 1, 10)) if (name && !extract_name(header, qlen, &p, name, 1, 10))
return 0; /* bad packet */ return 0; /* bad packet */
if (!name && !(p = skip_name(p, header, qlen, 10)))
return 0;
GETSHORT(qtype, p); GETSHORT(qtype, p);
GETSHORT(qclass, p); GETSHORT(qclass, p);
GETLONG(ttl, p); GETLONG(ttl, p);
GETSHORT(rdlen, p); GETSHORT(rdlen, p);
if (ttlp)
*ttlp = ttl;
if (qclass == C_IN && qtype == T_A) if (qclass == C_IN && qtype == T_A)
{ {
if (!CHECK_LEN(header, p, qlen, INADDRSZ)) if (!CHECK_LEN(header, p, qlen, INADDRSZ))
return 0; return 0;
for (baddrp = baddr; baddrp; baddrp = baddrp->next) for (baddrp = baddr; baddrp; baddrp = baddrp->next)
if (memcmp(&baddrp->addr, p, INADDRSZ) == 0) {
{ memcpy(&addr, p, INADDRSZ);
/* Found a bogus address. Insert that info here, since there no S
OA record
to get the ttl from in the normal processing */
cache_start_insert();
cache_insert(name, NULL, C_IN, now, ttl, F_IPV4 | F_FORWARD | F_N
EG | F_NXDOMAIN);
cache_end_insert();
if ((addr.s_addr & baddrp->mask.s_addr) == baddrp->addr.s_addr)
return 1; return 1;
} }
} }
if (!ADD_RDLEN(header, p, qlen, rdlen)) if (!ADD_RDLEN(header, p, qlen, rdlen))
return 0; return 0;
} }
return 0; return 0;
} }
int check_for_ignored_address(struct dns_header *header, size_t qlen, struct bog /* Is the packet a reply with the answer address equal to addr?
us_addr *baddr) If so mung is into an NXDOMAIN reply and also put that information
in the cache. */
int check_for_bogus_wildcard(struct dns_header *header, size_t qlen, char *name,
time_t now)
{ {
unsigned char *p; unsigned long ttl;
int i, qtype, qclass, rdlen;
struct bogus_addr *baddrp;
/* skip over questions */
if (!(p = skip_questions(header, qlen)))
return 0; /* bad packet */
for (i = ntohs(header->ancount); i != 0; i--) if (check_bad_address(header, qlen, daemon->bogus_addr, name, &ttl))
{ {
if (!(p = skip_name(p, header, qlen, 10))) /* Found a bogus address. Insert that info here, since there no SOA record
return 0; /* bad packet */ to get the ttl from in the normal processing */
cache_start_insert();
cache_insert(name, NULL, C_IN, now, ttl, F_IPV4 | F_FORWARD | F_NEG | F_NX
DOMAIN);
cache_end_insert();
GETSHORT(qtype, p); return 1;
GETSHORT(qclass, p);
p += 4; /* TTL */
GETSHORT(rdlen, p);
if (qclass == C_IN && qtype == T_A)
{
if (!CHECK_LEN(header, p, qlen, INADDRSZ))
return 0;
for (baddrp = baddr; baddrp; baddrp = baddrp->next)
if (memcmp(&baddrp->addr, p, INADDRSZ) == 0)
return 1;
}
if (!ADD_RDLEN(header, p, qlen, rdlen))
return 0;
} }
return 0; return 0;
} }
int check_for_ignored_address(struct dns_header *header, size_t qlen)
{
return check_bad_address(header, qlen, daemon->ignore_addr, NULL, NULL);
}
int add_resource_record(struct dns_header *header, char *limit, int *truncp, int nameoffset, unsigned char **pp, int add_resource_record(struct dns_header *header, char *limit, int *truncp, int nameoffset, unsigned char **pp,
unsigned long ttl, int *offset, unsigned short type, unsi gned short class, char *format, ...) unsigned long ttl, int *offset, unsigned short type, unsi gned short class, char *format, ...)
{ {
va_list ap; va_list ap;
unsigned char *sav, *p = *pp; unsigned char *sav, *p = *pp;
int j; int j;
unsigned short usval; unsigned short usval;
long lval; long lval;
char *sval; char *sval;
 End of changes. 14 change blocks. 
45 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)