Created
April 26, 2013 11:39
-
-
Save Habbie/5466634 to your computer and use it in GitHub Desktop.
Splits large TXT records into max 255-byte chunks, like BIND and friends.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- backup/pdns-2.9.21.2/pdns/dnswriter.cc 2007-04-21 07:56:36.000000000 -0600 | |
+++ pdns-2.9.21.2/pdns/dnswriter.cc 2008-12-01 12:10:28.000000000 -0700 | |
@@ -3,6 +3,7 @@ | |
#include "dnsparser.hh" | |
#include <boost/tokenizer.hpp> | |
#include <boost/algorithm/string.hpp> | |
+#include <limits.h> | |
DNSPacketWriter::DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t qtype, uint16_t qclass, uint8_t opcode) | |
: d_pos(0), d_content(content), d_qname(qname), d_qtype(qtype), d_qclass(qclass) | |
@@ -117,6 +118,8 @@ | |
d_record.push_back(val); | |
} | |
+#define MIN(a,b) (a < b ? a : b) | |
+ | |
void DNSPacketWriter::xfrText(const string& text, bool) | |
{ | |
escaped_list_separator<char> sep('\\', ' ' , '"'); | |
@@ -129,9 +132,11 @@ | |
} | |
else | |
for(; beg!=tok.end(); ++beg){ | |
- d_record.push_back(beg->length()); | |
- const uint8_t* ptr=(uint8_t*)(beg->c_str()); | |
- d_record.insert(d_record.end(), ptr, ptr+beg->length()); | |
+ for (unsigned int i = 0; i < beg->length(); i += UCHAR_MAX){ | |
+ d_record.push_back(MIN(UCHAR_MAX, beg->length()-i)); | |
+ const uint8_t* ptr=(uint8_t*)(beg->c_str()) + i; | |
+ d_record.insert(d_record.end(), ptr, ptr+MIN(UCHAR_MAX,beg->length()-i)); | |
+ } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment