dnsa the DNS answer block
rr the RR
-Returns: pointer to a chain of dns_address items
+Returns: pointer to a chain of dns_address items; NULL when the dnsa was overrun
*/
dns_address *
dns_address_from_rr(dns_answer *dnsa, dns_record *rr)
{
-dns_address *yield = NULL;
-
-dnsa = dnsa; /* Stop picky compilers warning */
+dns_address * yield = NULL;
+uschar * dnsa_lim = dnsa->answer + dnsa->answerlen;
if (rr->type == T_A)
{
uschar *p = US rr->data;
- yield = store_get(sizeof(dns_address) + 20);
- (void)sprintf(CS yield->address, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
- yield->next = NULL;
+ if (p + 4 <= dnsa_lim)
+ {
+ yield = store_get(sizeof(dns_address) + 20);
+ (void)sprintf(CS yield->address, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+ yield->next = NULL;
+ }
}
#if HAVE_IPV6
else
{
- yield = store_get(sizeof(dns_address) + 50);
- inet_ntop(AF_INET6, US rr->data, CS yield->address, 50);
- yield->next = NULL;
+ if (rr->data + 16 <= dnsa_lim)
+ {
+ yield = store_get(sizeof(dns_address) + 50);
+ inet_ntop(AF_INET6, US rr->data, CS yield->address, 50);
+ yield->next = NULL;
+ }
}
#endif /* HAVE_IPV6 */
}
for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
- rr != NULL;
+ rr;
rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT))
- {
- if (rr->type == type) count++;
- }
+ if (rr->type == type)
+ count++;
yield = store_get(sizeof(struct hostent));
alist = store_get((count + 1) * sizeof(char **));
yield->h_addr_list = CSS alist;
for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
- rr != NULL;
+ rr;
rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT))
{
int i, n;
int x[4];
dns_address *da;
if (rr->type != type) continue;
- da = dns_address_from_rr(&dnsa, rr);
+ if (!(da = dns_address_from_rr(&dnsa, rr))) break;
*alist++ = adds;
n = host_aton(da->address, x);
for (i = 0; i < n; i++)
fully_qualified_name = NULL;
for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
- rr != NULL;
+ rr;
rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT))
{
if (rr->type == type)
DEBUG(D_host_lookup)
{
- if (da == NULL)
- debug_printf("no addresses extracted from A6 RR for %s\n",
+ if (!da) debug_printf("no addresses extracted from A6 RR for %s\n",
host->name);
}
/* This loop runs only once for A and AAAA records, but may run
several times for an A6 record that generated multiple addresses. */
- for (; da != NULL; da = da->next)
+ for (; da; da = da->next)
{
#ifndef STAND_ALONE
if (ignore_target_hosts != NULL &&
if (type == T_A || type == T_AAAA || type == T_ADDRESSES)
{
dns_address *da;
- for (da = dns_address_from_rr(&dnsa, rr); da != NULL; da = da->next)
+ for (da = dns_address_from_rr(&dnsa, rr); da; da = da->next)
{
if (ptr != 0) yield = string_cat(yield, &size, &ptr, outsep, 1);
yield = string_cat(yield, &size, &ptr, da->address,
dns_record *rr;
dns_address **addrp = &(cb->rhs);
for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS);
- rr != NULL;
+ rr;
rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT))
{
if (rr->type == T_A)
{
dns_address *da = dns_address_from_rr(&dnsa, rr);
- if (da != NULL)
+ if (da)
{
*addrp = da;
while (da->next != NULL) da = da->next;
****
# Sender host name and address etc, all unset
exim -be
+-be Sender host name and address etc, all unset
-oMa sender_host_address = $sender_host_address
sender_host_port = $sender_host_port
-oMaa sender_host_authenticated = $sender_host_authenticated
****
# Sender host name and address etc, all set except host name.
exim -d-all+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
+-be Sender host name and address etc, all set except host name.
-oMa sender_host_address = $sender_host_address
sender_host_port = $sender_host_port
-oMaa sender_host_authenticated = $sender_host_authenticated
****
# Sender host name explicitly set
exim -be -oMa V4NET.0.0.1.1234 -oMs my.host.name
+-be Sender host name explicitly set
-oMa sender_host_address = $sender_host_address
sender_host_port = $sender_host_port
-oMs sender_host_name = $sender_host_name
****
# Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
exim -be -oMa V4NET.11.12.13
+be Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
-oMs sender_host_name = $sender_host_name
host_lookup_failed = $host_lookup_failed
****
# Sender host name and protocol set by Sendmail-compatible option
exim -be -pspecial:host.name
+-be Sender host name and protocol set by Sendmail-compatible option
-p received_protocol = $received_protocol
-p sender_host_name = $sender_host_name
****
# we are skipping. The debug output for this test will show when
# the lookup occurs.
exim -d-all+host_lookup+expand -be -oMa V4NET.0.0.1.1234 -oMaa AAA -oMai philip -oMas xx@yy.zz -oMi 1.1.1.1.99 -oMr special -oMt me
+-be Sender host name and address etc, all set except host name
-oMa sender_host_address = $sender_host_address
sender_host_port = $sender_host_port
-oMaa sender_host_authenticated = $sender_host_authenticated
>>> name=manyhome.test.ex address=10.250.104.60
>>> name=manyhome.test.ex address=10.250.104.61
>>> name=manyhome.test.ex address=10.250.104.62
->>> name=manyhome.test.ex address=0.0.0.0
>>> checking addresses for manyhome.test.ex
>>> 10.250.104.0
>>> 10.250.104.1
> yes
> match_address: no
>
+> -be Sender host name and address etc, all unset
> -oMa sender_host_address =
> sender_host_port = 0
> -oMaa sender_host_authenticated =
> -oMs sender_host_name =
> -oMt sender_ident = CALLER
>
+> -be Sender host name and address etc, all set except host name.
> -oMa sender_host_address = V4NET.0.0.1
> sender_host_port = 1234
> -oMaa sender_host_authenticated = AAA
> -oMr received_protocol = special
> -oMt sender_ident = me
>
+> -be Sender host name explicitly set
> -oMa sender_host_address = V4NET.0.0.1
> sender_host_port = 1234
> -oMs sender_host_name = my.host.name
>
+> be Sender host name lookup fails (V4NET.11.12.13 is not reverse registered)
> -oMs sender_host_name =
> host_lookup_failed = 1
>
+> -be Sender host name and protocol set by Sendmail-compatible option
> -p received_protocol = special
> -p sender_host_name = host.name
>
+> -be Sender host name and address etc, all set except host name
> -oMa sender_host_address = V4NET.0.0.1
> sender_host_port = 1234
> -oMaa sender_host_authenticated = AAA