-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop introduced in 1.5.4 #146
Comments
Same for me |
Just tagging @mikepultz for visibility |
Same for me |
Same for me 🤓 Code to reproduce: <?php
require 'vendor/autoload.php';
$resolver = new Net_DNS2_Resolver(['nameservers' => ['8.8.8.8']]);
$resolver->query('peopleinsight.co.uk', 'TXT');
//same here:
//$resolver->query('nl-sent.de', 'TXT');
//$resolver->query('algarvedreamproperty.com', 'TXT');
//$resolver->query('perpetual.com.au', 'TXT');
//$resolver->query('manage401k.com', 'TXT'); Fix in Names.php: public static function unpack($rdata, &$offset)
{
if ($offset > strlen($rdata)) {
return null;
}
$name = '';
$len = ord($rdata[$offset++]);
if ($len == 0) {
return null;
}
//$offset++;
//moved above to $len = ord($rdata[$offset++]);
if (($len + $offset) > strlen($rdata)) {
$name = substr($rdata, $offset);
} else {
$name = substr($rdata, $offset, $len);
}
$offset += strlen($name);
return $name;
} |
@mikepultz we are using this library in our project and having problems related to this ticket. can you tag the library with this fix? or should we fork? |
I've used pear/net_dns2^1.5.2, which has no issue and works just fine. |
@mikepultz Also had to switch back to pear/net_dns2^1.5.2: Is it going to be fixed? |
We actually ran into the "...multi-line TXT records that might happen to have a trailing period before the line break" issue that exists in 1.5.2 but is fixed in 1.5.3/1.5.4 and as we need it fixed we decided to upgrade to 1.5.4 and added a custom patch based on chaosben's fix using vaimo/composer-patches. # patches/fix_infinite_loop.patch
@package pear/net_dns2
diff --git a/Net/DNS2/Names.php b/Net/DNS2/Names.php
index 2cc7831..2dc26dc 100644
--- a/Net/DNS2/Names.php
+++ b/Net/DNS2/Names.php
@@ -83,13 +83,11 @@ class Net_DNS2_Names
$name = '';
- $len = ord($rdata[$offset]);
+ $len = ord($rdata[$offset++]);
if ($len == 0)
{
return null;
}
-
- $offset++;
if ( ($len + $offset) > strlen($rdata)) { It has been running in production just fine for the last 3 weeks now. |
very annoying bug :( |
Feel free to fix it =) |
@evgenyneverov, I am not quite sure what the point of your comment is, as the issue is not how to fix it, but to fix it. @mikepultz has not responded to this issue so far and there actually is a fix by @dheineman. This needs to added to the official code and this is not something @Pascal76 can do, so I am not sure what you were trying to say here. |
Version 1.5.4 introduced an infinite loop in certain scenario's.
Line triggering the issue: v1.5.2...v1.5.4#diff-132c1f6c93734535818a6b91db4260dfd1c0433a9a5ce32e9012d9f05d9f7887R96
Reason:
The text was updated successfully, but these errors were encountered: