ref: 70dfc2d75689339215d26637182830fc7348348b
parent: f67c4c85232b032f1825de30f4f943789257984e
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Nov 1 20:00:22 EDT 2023
ndb/dns: fix memory leak in dnzone()
--- a/sys/src/cmd/ndb/dntcpserver.c
+++ b/sys/src/cmd/ndb/dntcpserver.c
@@ -216,10 +216,8 @@
repp->id = reqp->id;
repp->qd = reqp->qd;
reqp->qd = reqp->qd->next;
- repp->qd->next = 0;
+ repp->qd->next = nil;
repp->flags = Fauth | Fresp | Oquery;
- if(!cfg.nonrecursive)
- repp->flags |= Fcanrec;
setercode(repp, Rok);
dp = repp->qd->owner;
@@ -233,12 +231,10 @@
repp->an = nil;
}
rv = reply(fd, pkt, repp, req, callip);
- if(repp->an == nil)
+ if(rv < 0 || repp->an == nil)
goto out;
rrfreelist(repp->an);
repp->an = nil;
- if(rv < 0)
- goto out;
repp->an = rrgetzone(dp->name);
while(repp->an != nil) {
@@ -254,9 +250,9 @@
/* resend the soa */
repp->an = rrlookup(dp, Tsoa, NOneg);
rv = reply(fd, pkt, repp, req, callip);
+out:
rrfreelist(repp->an);
repp->an = nil;
-out:
rrfree(repp->qd);
repp->qd = nil;
return rv;