Commit Diff
Diff:
516f5e8a298d3b15e49839e304c4c7bfa6d478d5
a86cc58a0b93976e62fddf326650d42bc058f888
Commit:
a86cc58a0b93976e62fddf326650d42bc058f888
Tree:
8c09911384238f290df5ce73cb9fbab21222f296
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Jan 14 12:42:04 2020 UTC
Message:
- fix a warning - make sure that linux uses libbsd's _SAFE bsd/sys/queue.h macros by removing ifdef's and include to sys/queue.h which was doubly included. - increase tcpentry's char buf by one in order to escape a possible overflow. This was never exploitable in the past though.
blob - 0e6bf57aaa6205a0abce2752ad8ab48bbc9c7f6d
blob + 16c9a3e819d6d92ff8a8d9569baa3ccba80765ba
--- axfr.c
+++ axfr.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: axfr.c,v 1.39 2019/12/10 12:44:10 pjp Exp $
+ * $Id: axfr.c,v 1.40 2020/01/14 12:42:04 pjp Exp $
*/
#include <sys/types.h>
@@ -403,11 +403,7 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
* go through every zone, removing those with all
* IP's notified...
*/
-#if __linux__
- SLIST_FOREACH(notnp, &notifyhead, notify_entry) {
-#else
SLIST_FOREACH_SAFE(notnp, &notifyhead, notify_entry, notn2) {
-#endif
count = 0;
SLIST_FOREACH(md, &notnp->mzone->dest, entries) {
if (md->notified == 0)
@@ -707,11 +703,7 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
}
-#ifdef __linux__
- SLIST_FOREACH(notnp, &notifyhead, notify_entry) {
-#else
SLIST_FOREACH_SAFE(notnp, &notifyhead, notify_entry, notn2) {
-#endif
for (i = 0; i < notify; i++) {
if (check_notifyreply(dh, question,
(struct sockaddr_storage *) sin, AF_INET, notnp, i) < 0) {
@@ -804,11 +796,7 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
}
-#ifdef __linux
- SLIST_FOREACH(notnp, &notifyhead, notify_entry) {
-#else
SLIST_FOREACH_SAFE(notnp, &notifyhead, notify_entry, notn2) {
-#endif
for (i = 0; i < notify; i++) {
if (check_notifyreply(dh, question,
(struct sockaddr_storage *) sin6, AF_INET6, notnp, i) < 0) {
@@ -1561,11 +1549,7 @@ notifyslaves(int *notifyfd)
i = 0;
-#ifdef __linux__
- SLIST_FOREACH(notnp, &notifyhead, notify_entry) {
-#else
SLIST_FOREACH_SAFE(notnp, &notifyhead, notify_entry, notn2) {
-#endif
remove = 0;
SLIST_FOREACH(md, &notnp->mzone->dest, entries) {
if (md->notifydest.ss_family == AF_INET)
@@ -1786,11 +1770,7 @@ check_notifyreply(struct dns_header *dh, struct questi
return -1;
}
-#if __linux__
- SLIST_FOREACH(md, &notnp->mzone->dest, entries) {
-#else
SLIST_FOREACH_SAFE(md, &notnp->mzone->dest, entries, md2) {
-#endif
if (md->notifydest.ss_family != af)
continue;
blob - a63d8e297a6f2c7d3d48c2808d2fde4f411bf01e
blob + 76f0e30ff8b430af732df6ab830d84a9a369aa97
--- db.c
+++ db.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: db.c,v 1.16 2019/12/07 08:01:48 pjp Exp $
+ * $Id: db.c,v 1.17 2020/01/14 12:42:04 pjp Exp $
*/
#include <sys/types.h>
@@ -288,11 +288,7 @@ add_rr(struct rbtree *rbt, char *name, int len, u_int1
struct rrset *rp0, *rp;
struct rr *rt;
-#ifdef __linux__
- TAILQ_FOREACH(rp, &rbt->rrset_head, entries) {
-#else
TAILQ_FOREACH_SAFE(rp, &rbt->rrset_head, entries, rp0) {
-#endif
if (rrtype == rp->rrtype)
break;
}
@@ -331,11 +327,7 @@ find_rr(struct rbtree *rbt, u_int16_t rrtype)
{
struct rrset *rp = NULL, *rp0 = NULL;
-#ifdef __linux__
- TAILQ_FOREACH(rp, &rbt->rrset_head, entries) {
-#else
TAILQ_FOREACH_SAFE(rp, &rbt->rrset_head, entries, rp0) {
-#endif
if (rrtype == rp->rrtype)
break;
}
@@ -354,11 +346,10 @@ display_rr(struct rrset *rrset)
{
struct rr *rrp, *rrp0;
-#ifdef __linux__
- TAILQ_FOREACH(rrp, &rrset->rr_head, entries) {
+ TAILQ_FOREACH_SAFE(rrp, &rrset->rr_head, entries, rrp0) {
+#if __linux__
printf("%ld:%u:%s\n", rrp->changed, rrp->ttl, (char *)rrp->rdata);
#else
- TAILQ_FOREACH_SAFE(rrp, &rrset->rr_head, entries, rrp0) {
printf("%lld:%u:%s\n", rrp->changed, rrp->ttl, (char *)rrp->rdata);
#endif
}
blob - dd0be7209d42ae708cd24f29b0296dd1e31d1cca
blob + cc3f36b4078224baceaf090be5d75fe0649219a5
--- dddctl.c
+++ dddctl.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: dddctl.c,v 1.94 2019/12/27 15:16:52 pjp Exp $
+ * $Id: dddctl.c,v 1.95 2020/01/14 12:42:04 pjp Exp $
*/
#include <sys/param.h>
@@ -2236,11 +2236,7 @@ sign_txt(ddDB *db, char *zonename, struct keysentry *z
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -2450,11 +2446,7 @@ sign_aaaa(ddDB *db, char *zonename, struct keysentry *
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -3331,11 +3323,7 @@ sign_naptr(ddDB *db, char *zonename, struct keysentry
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -3551,11 +3539,7 @@ sign_srv(ddDB *db, char *zonename, struct keysentry *z
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -3770,11 +3754,7 @@ sign_sshfp(ddDB *db, char *zonename, struct keysentry
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -3991,11 +3971,7 @@ sign_tlsa(ddDB *db, char *zonename, struct keysentry *
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -4211,11 +4187,7 @@ sign_ds(ddDB *db, char *zonename, struct keysentry *z
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -4423,11 +4395,7 @@ sign_ns(ddDB *db, char *zonename, struct keysentry *zs
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -4637,11 +4605,7 @@ sign_mx(ddDB *db, char *zonename, struct keysentry *zs
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -4850,11 +4814,7 @@ sign_a(ddDB *db, char *zonename, struct keysentry *zsk
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -5257,11 +5217,7 @@ sign_dnskey(ddDB *db, char *zonename, struct keysentry
}
- #ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
- #else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
- #endif
pack(p, c2->data, c2->len);
p += c2->len;
@@ -5416,11 +5372,7 @@ sign_dnskey(ddDB *db, char *zonename, struct keysentry
}
}
-#ifdef __linux__
- TAILQ_FOREACH(c2, &head, entries) {
-#else
TAILQ_FOREACH_SAFE(c2, &head, entries, cp) {
-#endif
pack(p, c2->data, c2->len);
p += c2->len;
blob - e5e7034f3aea8e2cb174986abb19428d9715feda
blob + cd80deb9746a8497b7c0d5e157e696a264b6f922
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.97 2020/01/01 14:55:22 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.98 2020/01/14 12:42:04 pjp Exp $
*/
@@ -36,7 +36,6 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/uio.h>
-#include <sys/queue.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/un.h>
@@ -243,7 +242,7 @@ struct tcpentry {
int seen; /* seen heading bytes */
int so;
time_t last_used;
- char buf[0xffff + 2];
+ char buf[0xffff + 3];
char *address;
TAILQ_ENTRY(tcpentry) tcpentries;
} *tcpn1, *tcpn2, *tcpnp;
@@ -2360,7 +2359,7 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
{
fd_set rset;
int sel;
- int len, slen = 0, length = 0;
+ int len, slen = 0;
int is_ipv6;
int i;
int istcp = 1;
@@ -2502,12 +2501,7 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
}
if (sel == 0) {
-#ifndef __linux__
TAILQ_FOREACH_SAFE(tcpnp, &tcphead, tcpentries, tcpn1) {
-#else
- TAILQ_FOREACH(tcpnp, &tcphead, tcpentries) {
-#endif
-
if ((tcpnp->last_used + 3) < time(NULL)) {
dolog(LOG_INFO, "tcp timeout on interface \"%s\" for address %s\n", cfg->ident[tcpnp->intidx], tcpnp->address);
TAILQ_REMOVE(&tcphead, tcpnp, tcpentries);
@@ -2630,11 +2624,7 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
} /* FD_ISSET */
}
-#ifndef __linux__
TAILQ_FOREACH_SAFE(tcpnp, &tcphead, tcpentries, tcpn1) {
-#else
- TAILQ_FOREACH(tcpnp, &tcphead, tcpentries) {
-#endif
if (FD_ISSET(tcpnp->so, &rset)) {
if (tcpnp->bytes_read < 2)
@@ -2662,7 +2652,10 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
tcpnp->bytes_expected = 0;
if (tcpnp->seen == 0 && tcpnp->bytes_read >= 2) {
- tcpnp->bytes_expected = ntohs(*((u_int16_t *)&tcpnp->buf[0]));
+ uint16_t u16tmp;
+
+ u16tmp = unpack16(&tcpnp->buf[0]);
+ tcpnp->bytes_expected = ntohs(u16tmp);
tcpnp->bytes_limit = tcpnp->bytes_expected;
tcpnp->seen = 1;
}
@@ -3155,11 +3148,7 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
* kick off the idlers
*/
-#ifndef __linux__
TAILQ_FOREACH_SAFE(tcpnp, &tcphead, tcpentries, tcpn1) {
-#else
- TAILQ_FOREACH(tcpnp, &tcphead, tcpentries) {
-#endif
if ((tcpnp->last_used + 3) < time(NULL)) {
dolog(LOG_INFO, "tcp timeout on interface \"%s\" for address %s\n", cfg->ident[tcpnp->intidx], tcpnp->address);
TAILQ_REMOVE(&tcphead, tcpnp, tcpentries);
blob - dd156b8b1e04abb2445898bdf10045f57a14f150
blob + c99812bdf33f9fe0393050d3f3d00a2538853dc0
--- raxfr.c
+++ raxfr.c
@@ -26,13 +26,12 @@
*
*/
/*
- * $Id: raxfr.c,v 1.46 2019/12/11 16:22:26 pjp Exp $
+ * $Id: raxfr.c,v 1.47 2020/01/14 12:42:05 pjp Exp $
*/
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
-#include <sys/queue.h>
#include <sys/uio.h>
#include <sys/stat.h>
@@ -1297,11 +1296,7 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
lastnow = time(NULL);
-#ifdef __linux__
- SLIST_FOREACH(lrz, &rzones, rzone_entry) {
-#else
SLIST_FOREACH_SAFE(lrz, &rzones, rzone_entry, lrz0) {
-#endif
if (lrz->zonename == NULL)
continue;
@@ -1346,11 +1341,7 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
period = (tot_refresh / zonecount) / zonecount;
add_period = period;
-#ifdef __linux__
- SLIST_FOREACH(lrz, &rzones, rzone_entry) {
-#else
SLIST_FOREACH_SAFE(lrz, &rzones, rzone_entry, lrz0) {
-#endif
if (lrz->zonename == NULL)
continue;
@@ -1483,11 +1474,7 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
continue;
}
-#ifdef __linux__
- LIST_FOREACH(sp0, &myschedules, myschedule_entry) {
-#else
LIST_FOREACH_SAFE(sp0, &myschedules, myschedule_entry, sp1) {
-#endif
if (sp0->when <= now) {
/* we hit a timeout on refresh */
if (sp0->action == SCHEDULE_ACTION_REFRESH) {
repomaster@centroid.eu