diff options
Diffstat (limited to 'net-dns/djbdns/files/djbdns-dnscache-configurable-truncate-size-nov6.patch')
-rw-r--r-- | net-dns/djbdns/files/djbdns-dnscache-configurable-truncate-size-nov6.patch | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/net-dns/djbdns/files/djbdns-dnscache-configurable-truncate-size-nov6.patch b/net-dns/djbdns/files/djbdns-dnscache-configurable-truncate-size-nov6.patch new file mode 100644 index 000000000000..d855c212d198 --- /dev/null +++ b/net-dns/djbdns/files/djbdns-dnscache-configurable-truncate-size-nov6.patch @@ -0,0 +1,78 @@ +diff --git a/dnscache.c b/dnscache.c +index 8c899a3..8b10571 100644 +--- a/dnscache.c ++++ b/dnscache.c +@@ -51,6 +51,7 @@ static char myipincoming[4]; + static char buf[1024]; + uint64 numqueries = 0; + ++static unsigned int truncate_len = 512; + + static int udp53; + +@@ -77,7 +78,7 @@ void u_respond(int j) + { + if (!u[j].active) return; + response_id(u[j].id); +- if (response_len > 512) response_tc(); ++ if (response_len > truncate_len) response_tc(); + socket_send4(udp53,response,response_len,u[j].ip,u[j].port); + log_querydone(&u[j].active,response_len); + u[j].active = 0; --uactive; +@@ -431,6 +432,15 @@ int main() + if (!cache_init(cachesize)) + strerr_die3x(111,FATAL,"not enough memory for cache of size ",x); + ++ x = env_get("TRUNCATELEN"); ++ if (x) { ++ scan_ulong(x,&truncate_len); ++ if (truncate_len < 512) ++ truncate_len = 512; ++ if (truncate_len > 16384) ++ truncate_len = 16384; ++ } ++ + if (env_get("HIDETTL")) + response_hidettl(); + if (env_get("FORWARDONLY")) +diff --git a/server.c b/server.c +index e486fe1..63ad11c 100644 +--- a/server.c ++++ b/server.c +@@ -2,6 +2,7 @@ + #include "case.h" + #include "env.h" + #include "buffer.h" ++#include "scan.h" + #include "strerr.h" + #include "ip4.h" + #include "uint16.h" +@@ -83,6 +84,7 @@ int main() + { + char *x; + int udp53; ++ unsigned int truncate_len = 512; + + x = env_get("IP"); + if (!x) +@@ -105,11 +107,19 @@ int main() + + buffer_putsflush(buffer_2,starting); + ++ x = env_get("TRUNCATELEN"); ++ if (x) { ++ scan_ulong(x,&truncate_len); ++ if (truncate_len < 512) ++ truncate_len = 512; ++ if (truncate_len > 16384) ++ truncate_len = 16384; ++ } + for (;;) { + len = socket_recv4(udp53,buf,sizeof buf,ip,&port); + if (len < 0) continue; + if (!doit()) continue; +- if (response_len > 512) response_tc(); ++ if (response_len > truncate_len) response_tc(); + socket_send4(udp53,response,response_len,ip,port); + /* may block for buffer space; if it fails, too bad */ + } |