Commit Diff
Diff:
51915c1ddf7026ebee8e00d882e947b9c2e75e4c
0afcc5acafa2254021262cc8a8d7e06407794f40
Commit:
0afcc5acafa2254021262cc8a8d7e06407794f40
Tree:
e8b2085275a4da28c3b1716d69968a33c77b88fa
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Mon Jun 29 16:54:47 2020 UTC
Message:
I'm still paranoid about the size of this buffer "buf"... put it on the heap and make it bigger
blob - b9e43a8a3aca04bb8bad0544696292c06562fe98
blob + 33ffb46d28deb5f7d2833dfc416012c8e51c736f
--- axfr.c
+++ axfr.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: axfr.c,v 1.44 2020/06/29 16:22:05 pjp Exp $
+ * $Id: axfr.c,v 1.45 2020/06/29 16:54:47 pjp Exp $
*/
#include <sys/types.h>
@@ -838,9 +838,9 @@ void
axfr_connection(int so, char *address, int is_ipv6, ddDB *db, char *packet, int packetlen)
{
- char buf[4000];
+ char *buf;
char tsigkey[512];
- char *p = &buf[0];
+ char *p;
char *q;
char *reply, *replybuf;
@@ -863,7 +863,18 @@ axfr_connection(int so, char *address, int is_ipv6, dd
ddDBT key, data;
HMAC_CTX *tsigctx = NULL;
+
+#define DDD_AXFR_RECBUF (0xffff + 3)
+
+ if ((buf = calloc(1, DDD_AXFR_RECBUF)) == NULL) {
+ dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
+ close(so);
+ exit(1);
+ }
+
+ p = &buf[0];
+
if ((replybuf = calloc(1, 0xffff + 3)) == NULL) {
dolog(LOG_ERR, "calloc: %s\n", strerror(errno));
close(so);
@@ -871,7 +882,7 @@ axfr_connection(int so, char *address, int is_ipv6, dd
}
- if (packetlen > sizeof(buf)) {
+ if (packetlen > DDD_AXFR_RECBUF) {
dolog(LOG_ERR, "buffer size of buf is smaller than given packet, drop\n");
close(so);
exit(1);
@@ -879,7 +890,7 @@ axfr_connection(int so, char *address, int is_ipv6, dd
for (;;) {
if (packetlen == 0) {
- len = recv(so, p + offset, sizeof(buf) - offset, 0);
+ len = recv(so, p + offset, DDD_AXFR_RECBUF - offset, 0);
if (len <= 0) {
close(so);
exit(1);
repomaster@centroid.eu