Skip to content

Commit a77ad84

Browse files
committed
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.
1 parent 921b873 commit a77ad84

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

encode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ State.prototype.encode = function(full_domain, position_offset, option) {
211211
, bytes
212212

213213
var i = 0
214-
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
214+
var max_iterations = 127 // Theoretical upper limit for number of labels in a DNS name; see https://en.wikipedia.org/wiki/Subdomain#Overview
215215

216216
while(++i < max_iterations) {
217217
if(domain == '') {

0 commit comments

Comments
 (0)