ndb/dns: handle dnskey RR's (thanks moody)

On 12/18/20, Jacob Moody wrote:
> Hello,
>
> I recently ran in to some issues with pointing an unbound server towards a
> 9front dns server as its upstream.
> The parsing seemed to fail when ndb/dns received a DNSKEY RR from it's own
> upstream source on behalf of unbound.
> This patch catches and stores the DNSKEY from the upstream server to prevent
> this.
This commit is contained in:
cinap_lenrek 2020-12-20 23:08:11 +01:00
parent e4ce6aadac
commit 41c60689b3
3 changed files with 7 additions and 0 deletions

View file

@ -275,6 +275,7 @@ convRR2M(RR *rp, uchar *p, uchar *ep, Dict *dp)
NAME(rp->rmb->name);
NAME(rp->rp->name);
break;
case Tdnskey:
case Tkey:
USHORT(rp->key->flags);
UCHAR(rp->key->proto);

View file

@ -448,6 +448,7 @@ retry:
rp->rmb = dnlookup(NAME(dname), Cin, 1);
rp->rp = dnlookup(NAME(dname), Cin, 1);
break;
case Tdnskey:
case Tkey:
USHORT(rp->key->flags);
UCHAR(rp->key->proto);

View file

@ -893,6 +893,7 @@ rrcopy(RR *rp, RR **last)
nrp->srv = srv;
*srv = *rp->srv;
break;
case Tdnskey:
case Tkey:
key = nrp->key;
*nrp = *rp;
@ -1273,6 +1274,7 @@ rrfmt(Fmt *f)
case Trp:
fmtprint(&fstr, "\t%s %s", dnname(rp->rmb), dnname(rp->rp));
break;
case Tdnskey:
case Tkey:
if (rp->key == nil)
fmtprint(&fstr, "\t<null> <null> <null>");
@ -1413,6 +1415,7 @@ rravfmt(Fmt *f)
idnname(rp->rmb, buf, sizeof(buf)),
idnname(rp->rp, buf, sizeof(buf)));
break;
case Tdnskey:
case Tkey:
if (rp->key == nil)
fmtprint(&fstr, " flags=<null> proto=<null> alg=<null>");
@ -1951,6 +1954,7 @@ rralloc(int type)
rp->srv = emalloc(sizeof(*rp->srv));
setmalloctag(rp->srv, rp->pc);
break;
case Tdnskey:
case Tkey:
rp->key = emalloc(sizeof(*rp->key));
setmalloctag(rp->key, rp->pc);
@ -1994,6 +1998,7 @@ rrfree(RR *rp)
memset(rp->srv, 0, sizeof *rp->srv); /* cause trouble */
free(rp->srv);
break;
case Tdnskey:
case Tkey:
free(rp->key->data);
memset(rp->key, 0, sizeof *rp->key); /* cause trouble */