From a77ad8411f56ba9983430db826de8eec3de769a9 Mon Sep 17 00:00:00 2001 From: fogs Date: Thu, 28 Apr 2016 07:53:37 +0200 Subject: [PATCH] Increased max_iterations Although 40 labels seems high enough for most use cases (e.g. reverse resolution of a IPv6 address) our project ran into issues with a domain name with 45 labels. To avoid problems in the future, I suggest to allow for the maximum number of labels allowed for a domain name. Since the function stops immediately when a shorter DNS name is processed, this should not have any impact for other users of this library. --- encode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encode.js b/encode.js index d0aa06f..de8e39e 100644 --- a/encode.js +++ b/encode.js @@ -211,7 +211,7 @@ State.prototype.encode = function(full_domain, position_offset, option) { , bytes var i = 0 - var max_iterations = 40 // Enough for 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa + var max_iterations = 127 // Theoretical upper limit for number of labels in a DNS name; see https://en.wikipedia.org/wiki/Subdomain#Overview while(++i < max_iterations) { if(domain == '') {