Skip to content

Commit

Permalink
dnsname: move len and offset from int to size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
chbruyand committed Jan 19, 2024
1 parent 0d2aa6c commit 7b3df79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pdns/dnsname.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ DNSName::DNSName(const std::string_view sw)
}
}


DNSName::DNSName(const char* pos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, uint16_t minOffset)
DNSName::DNSName(const char* pos, size_t len, size_t offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, uint16_t minOffset)
{
if (offset >= len)
throw std::range_error("Trying to read past the end of the buffer ("+std::to_string(offset)+ " >= "+std::to_string(len)+")");
Expand All @@ -115,7 +114,7 @@ DNSName::DNSName(const char* pos, int len, int offset, bool uncompress, uint16_t
}

// this should be the __only__ dns name parser in PowerDNS.
void DNSName::packetParser(const char* qpos, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, int depth, uint16_t minOffset)
void DNSName::packetParser(const char* qpos, size_t len, size_t offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, int depth, uint16_t minOffset)
{
const unsigned char* pos=(const unsigned char*)qpos;
unsigned char labellen;
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsname.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public:
DNSName(DNSName&& a) = default;

explicit DNSName(std::string_view sw); //!< Constructs from a human formatted, escaped presentation
DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype = nullptr, uint16_t* qclass = nullptr, unsigned int* consumed = nullptr, uint16_t minOffset = 0); //!< Construct from a DNS Packet, taking the first question if offset=12. If supplied, consumed is set to the number of bytes consumed from the packet, which will not be equal to the wire length of the resulting name in case of compression.
DNSName(const char* p, size_t len, size_t offset, bool uncompress, uint16_t* qtype = nullptr, uint16_t* qclass = nullptr, unsigned int* consumed = nullptr, uint16_t minOffset = 0); //!< Construct from a DNS Packet, taking the first question if offset=12. If supplied, consumed is set to the number of bytes consumed from the packet, which will not be equal to the wire length of the resulting name in case of compression.

bool isPartOf(const DNSName& rhs) const; //!< Are we part of the rhs name? Note that name.isPartOf(name).
inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty
Expand Down Expand Up @@ -216,7 +216,7 @@ public:
private:
string_t d_storage;

void packetParser(const char* p, int len, int offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, int depth, uint16_t minOffset);
void packetParser(const char* p, size_t len, size_t offset, bool uncompress, uint16_t* qtype, uint16_t* qclass, unsigned int* consumed, int depth, uint16_t minOffset);

Check warning on line 219 in pdns/dnsname.hh

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

function 'DNSName::packetParser' has a definition with different parameter names (readability-inconsistent-declaration-parameter-name - Level=Warning)

Check warning on line 219 in pdns/dnsname.hh

View workflow job for this annotation

GitHub Actions / Analyze (cpp, rec)

function 'DNSName::packetParser' has a definition with different parameter names (readability-inconsistent-declaration-parameter-name - Level=Warning)

Check warning on line 219 in pdns/dnsname.hh

View workflow job for this annotation

GitHub Actions / Analyze (cpp, dnsdist)

function 'DNSName::packetParser' has a definition with different parameter names (readability-inconsistent-declaration-parameter-name - Level=Warning)
static void appendEscapedLabel(std::string& appendTo, const char* orig, size_t len);
static std::string unescapeLabel(const std::string& orig);
static void throwSafeRangeError(const std::string& msg, const char* buf, size_t length);
Expand Down

0 comments on commit 7b3df79

Please sign in to comment.