Commit Diff
Diff:
3a82bbc8f1189ff2623a7b3a0e82d4fe40d0c32e
14b02e9aa126b9310b7479840d9d433251ee4ca4
Commit:
14b02e9aa126b9310b7479840d9d433251ee4ca4
Tree:
bd142422edbd95a25a535742020114ede57b8674
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Mar 1 05:36:50 2019 UTC
Message:
Make tsig_timers static, this saves us malloc/free'ing which can be costly
blob - 85cc809728df66ee7d8e90ae16168b7cb50ca443
blob + adbdc408fdd72aa94ee2bc5654df5b69760a916c
--- additional.c
+++ additional.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: additional.c,v 1.25 2019/02/28 08:54:29 pjp Exp $
+ * $Id: additional.c,v 1.26 2019/03/01 05:36:50 pjp Exp $
*/
#include "ddd-include.h"
@@ -367,7 +367,7 @@ additional_tsig(struct question *question, char *reply
int ppoffset = 0;
int ttlen = 0, rollback;
char *pseudo_packet = NULL;
- char *tsig_timers = NULL;
+ char tsig_timers[512];
struct dns_header *odh;
char tsigkey[512];
time_t now;
@@ -382,10 +382,6 @@ additional_tsig(struct question *question, char *reply
rollback = offset;
if (envelope > 1 || envelope < -1) {
- tsig_timers = malloc(replylen);
- if (tsig_timers == NULL)
- goto out;
-
ttlen = 0;
if (priordigest) {
sval = (u_int16_t *)&tsig_timers[ttlen];
@@ -395,6 +391,8 @@ additional_tsig(struct question *question, char *reply
memcpy(&tsig_timers[ttlen], question->tsig.tsigmac, question->tsig.tsigmaclen);
ttlen += question->tsig.tsigmaclen;
+ HMAC_Update(tsigctx, tsig_timers, ttlen);
+
priordigest = 0;
}
@@ -424,8 +422,7 @@ additional_tsig(struct question *question, char *reply
ppoffset += offset;
if (envelope > 1 || envelope < -1) {
- memcpy(&tsig_timers[ttlen], reply, offset);
- ttlen += offset;
+ HMAC_Update(tsigctx, reply, offset);
}
if ((tsignamelen = find_tsig_key(question->tsig.tsigkey,
@@ -567,13 +564,13 @@ additional_tsig(struct question *question, char *reply
if (envelope > 1 || envelope < -1) {
if (envelope % 89 == 0 || envelope == -2) {
+ ttlen = 0;
timers = (struct dns_tsigrr *)&tsig_timers[ttlen];
timers->timefudge = htobe64(((u_int64_t)now << 16) | (300 & 0xffff));
- //timers->timefudge = question->tsig.tsig_timefudge;
ttlen += 8;
+ HMAC_Update(tsigctx, (const unsigned char *)tsig_timers, ttlen);
}
- HMAC_Update(tsigctx, (const unsigned char *)tsig_timers, ttlen);
if (envelope % 89 == 0 || envelope == -2) {
macsize = 32;
@@ -583,7 +580,6 @@ additional_tsig(struct question *question, char *reply
} else
offset = rollback;
- free(tsig_timers);
} else {
if (question->tsig.tsigerrorcode == DNS_BADTIME) {
repomaster@centroid.eu