shithub: plan9front

Download patch

ref: 97c6a1dd521c893de2c26b8876cdda283fdd7dc8
parent: b0ae37013cf58b5cdeb67bb0b182669be1540aa9
author: cinap_lenrek <>
date: Wed Aug 18 13:59:50 EDT 2021

snoopy: fix dns nil pointer crashes when formating dns packets (thanks sl)

snoopy shares ndb/dns's dns parser code, but has its own
copy of rralloc() function, which is responsible to allocating
auxiolary data structures on an RR depending on the type.

ndb/dns gained some support for some new types, but snoopy's
copy of rralloc() was not updated, resulting the auxiolary
structures to be nil, and the shared parsing routines crashes
when trying to dereference them.

this just syncs the copies, we might consider moving rralloc()
into its own file so it can be completely shared.

--- a/sys/src/cmd/ip/snoopy/dns.c	Wed Aug 18 10:44:29 2021
+++ b/sys/src/cmd/ip/snoopy/dns.c	Wed Aug 18 13:59:50 2021
@@ -430,9 +430,14 @@
 		rp->srv = emalloc(sizeof(*rp->srv));
 		setmalloctag(rp->srv, rp->pc);
+	case Tdnskey:
 	case Tkey:
 		rp->key = emalloc(sizeof(*rp->key));
 		setmalloctag(rp->key, rp->pc);
+		break;
+	case Tcaa:
+		rp->caa = emalloc(sizeof(*rp->caa));
+		setmalloctag(rp->caa, rp->pc);
 	case Tcert:
 		rp->cert = emalloc(sizeof(*rp->cert));