From 1650b60234ad0a2da5fd0ee2e3d948ece571db56 Mon Sep 17 00:00:00 2001 From: Gaya Cohen Date: Mon, 24 May 2021 17:04:11 +0300 Subject: [PATCH] change counter variable type and add exception description comment --- include/tins/exceptions.h | 3 +++ src/dns.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/tins/exceptions.h b/include/tins/exceptions.h index 3ef91ba..a2583ae 100644 --- a/include/tins/exceptions.h +++ b/include/tins/exceptions.h @@ -66,6 +66,9 @@ public: malformed_packet() : exception_base("Malformed packet") { } }; +/** + * \brief Exception thrown when a DNS decompression pointer is out of bounds. + */ class DNS_decompression_pointer_out_of_bounds : public exception_base { public: DNS_decompression_pointer_out_of_bounds() : exception_base("DNS decompression pointer out of bounds") { } diff --git a/src/dns.cpp b/src/dns.cpp index 759ddde..a8853eb 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -336,7 +336,7 @@ uint32_t DNS::compose_name(const uint8_t* ptr, char* out_ptr) const { const uint8_t* end = &records_data_[0] + records_data_.size(); const uint8_t* end_ptr = 0; char* current_out_ptr = out_ptr; - int pointer_counter = 0; + uint8_t pointer_counter = 0; while (*ptr) { if (pointer_counter++ > 30){ throw DNS_decompression_pointer_loops();