summaryrefslogtreecommitdiffstats
path: root/src/dns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dns.c')
-rw-r--r--src/dns.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dns.c b/src/dns.c
index b070eba..cf089a8 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -53,6 +53,7 @@ const char* perf_dns_rcode_strings[] = {
perf_result_t perf_dname_fromstring(const char* str, size_t len, perf_buffer_t* target)
{
size_t label_len, at;
+ ssize_t max = 255;
const char* orig_str = str;
bool is_quoted;
@@ -101,6 +102,10 @@ perf_result_t perf_dname_fromstring(const char* str, size_t len, perf_buffer_t*
if (label_len > 63) {
return PERF_R_FAILURE;
}
+ max -= label_len + 1;
+ if (max < 0) {
+ return PERF_R_FAILURE;
+ }
perf_buffer_putuint8(target, label_len);
if (is_quoted) {
for (at = 0; at < len; at++) {