Show
Ignore:
Timestamp:
02/14/09 16:18:50 (4 years ago)
Author:
ahu
Message:

implement auto-splitting of long TXT entries, inspired by Derrik Pates. Closes ticket 188.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnswriter.cc

    r1258 r1340  
    44#include <boost/tokenizer.hpp> 
    55#include <boost/algorithm/string.hpp> 
     6#include <limits.h> 
    67 
    78DNSPacketWriter::DNSPacketWriter(vector<uint8_t>& content, const string& qname, uint16_t  qtype, uint16_t qclass, uint8_t opcode) 
     
    149150  else  
    150151    for(; beg!=tok.end(); ++beg){ 
    151       d_record.push_back(beg->length()); 
    152       const uint8_t* ptr=(uint8_t*)(beg->c_str()); 
    153       d_record.insert(d_record.end(), ptr, ptr+beg->length()); 
     152      if(beg->empty())  
     153        d_record.push_back(0); 
     154      else  
     155        for (unsigned int i = 0; i < beg->length(); i += 0xff){ 
     156          d_record.push_back(min(0xffU, beg->length()-i)); 
     157          const uint8_t* ptr=(uint8_t*)(beg->c_str()) + i; 
     158          d_record.insert(d_record.end(), ptr, ptr+min(0xffU, beg->length()-i)); 
     159        } 
    154160    } 
    155161}