Commit Diff
Diff:
a7747a523fe9c5865c9c66c636d98f76c5702952
5e61a9ef148ef7c3cc3a12fe1330b03ec351bd57
Commit:
5e61a9ef148ef7c3cc3a12fe1330b03ec351bd57
Tree:
538c5e3fe8fd88fcadf65e7afa7ca456c290c7c9
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Sun Feb 24 10:27:15 2019 UTC
Message:
delphinusdnsd would crash on a '.' reply refused instead, this is fallout from taking the goto's out I think. Also make sure we don't free a NULL
blob - e7fe2f0adfe1981410fa9bfc74c9d82b32381b34
blob + ab624a33d1879fef37c50f146837918b0111f673
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.55 2019/02/24 07:14:02 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.56 2019/02/24 10:27:15 pjp Exp $
*/
#include "ddd-include.h"
@@ -1304,9 +1304,11 @@ get_soa(ddDB *db, struct question *question)
rbt = find_rrset(db, p, plen);
if (rbt == NULL) {
+ if (*p == '\0')
+ return (NULL);
+
plen -= (*p + 1);
p = (p + (*p + 1));
- free (rbt);
continue;
}
@@ -1866,7 +1868,9 @@ axfrentry:
build_reply(&sreply, so, buf, len, question, from, fromlen, rbt1, rbt0, aregion, istcp, 0, NULL, replybuf);
slen = reply_nodata(&sreply, cfg->db);
} else {
- snprintf(replystring, DNS_MAXNAME, "DROP");
+ build_reply(&sreply, so, buf, len, question, from, fromlen, rbt1, rbt0, aregion, istcp, 0, NULL, replybuf);
+ slen = reply_refused(&sreply, cfg->db);
+ snprintf(replystring, DNS_MAXNAME, "REFUSED");
}
goto udpout;
break;
@@ -1896,6 +1900,8 @@ axfrentry:
slen = reply_noerror(&sreply, cfg->db);
}
+ snprintf(replystring, DNS_MAXNAME, "DROP");
+
goto udpout;
}
}
@@ -2699,7 +2705,9 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
build_reply(&sreply, so, pbuf, len, question, from, fromlen, rbt0, NULL, aregion, istcp, 0, NULL, replybuf);
slen = reply_nodata(&sreply, cfg->db);
} else {
- snprintf(replystring, DNS_MAXNAME, "DROP");
+ snprintf(replystring, DNS_MAXNAME, "REFUSED");
+ build_reply(&sreply, so, pbuf, len, question, from, fromlen, rbt0, NULL, aregion, istcp, 0, NULL, replybuf);
+ slen = reply_refused(&sreply, cfg->db);
}
goto tcpout;
@@ -2747,6 +2755,8 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
slen = reply_noerror(&sreply, cfg->db);
}
+
+ snprintf(replystring, DNS_MAXNAME, "DROP");
goto tcpout;
}
blob - c1bf340f7f1b58808ef0975d6b4732475bb09677
blob + 45b405c99dbeaae215c03c0030dcc9cc7b97d86a
--- util.c
+++ util.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: util.c,v 1.23 2019/02/24 07:14:02 pjp Exp $
+ * $Id: util.c,v 1.24 2019/02/24 10:27:15 pjp Exp $
*/
#include "ddd-include.h"
@@ -255,9 +255,17 @@ lookup_zone(ddDB *db, struct question *question, int *
if (check_ent(p, plen) == 1) {
*lzerrno = ERR_NODATA;
*returnval = -1;
+
+ /* stop leakage */
+ if (rrset != NULL)
+ free(rbt);
+
return NULL;
}
+ if (rrset != NULL)
+ free(rbt);
+
/*
* We have a condition where a record does not exist but we
* move toward the apex of the record, and there may be
@@ -268,18 +276,20 @@ lookup_zone(ddDB *db, struct question *question, int *
plen -= (*p + 1);
p = (p + (*p + 1));
- free(rbt);
+ /* rbt was NULL */
if ((rbt = find_rrset(db, p, plen)) != NULL) {
if (find_rr(rbt, DNS_TYPE_SOA) != NULL) {
*lzerrno = ERR_NXDOMAIN;
*returnval = -1;
return (rbt);
}
+
+ free(rbt);
}
}
*lzerrno = ERR_REFUSED;
*returnval = -1;
- return (rbt);
+ return (NULL);
}
snprintf(replystring, DNS_MAXNAME, "%s", rbt->humanname);
repomaster@centroid.eu