Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Records/TypeDefinitions/TypeDefinitionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private function setDefinitions()
'priority' => Types::SHORT,
'weight' => Types::SHORT,
'port' => Types::SHORT,
'name' => Types::DOMAIN_NAME | DomainName::FLAG_NO_COMPRESSION,
'name' => Types::DOMAIN_NAME | (DomainName::FLAG_NO_COMPRESSION << 16),
],
ResourceTypes::TXT => [ // RFC 1035
'txtdata+' => Types::CHARACTER_STRING,
Expand Down
2 changes: 1 addition & 1 deletion src/Records/Types/DomainName.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DomainName extends Type
{
const FLAG_NO_COMPRESSION = 0x80000000;
const FLAG_NO_COMPRESSION = 0x8000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this is a BC break. Should we just fix the usage and leave this as is?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the culprit, php triggers the deprecation on this very line. It's a too big number on 32bit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #28, WDYT?


/**
* @var string
Expand Down
10 changes: 6 additions & 4 deletions src/Records/Types/Long.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public function setValue($value)
{
$value = (int)$value;

if ($value < 0) {
throw new \UnderflowException('Long integer value must be in the range 0 - 4294967296');
} else if ($value > 0xffffffff) {
throw new \OverflowException('Long integer value must be in the range 0 - 4294967296');
if (4 !== \PHP_INT_SIZE) {
if ($value < 0) {
throw new \UnderflowException('Long integer value must be in the range 0 - 4294967296');
} else if ($value > 0xffffffff) {
throw new \OverflowException('Long integer value must be in the range 0 - 4294967296');
}
}
Comment on lines +41 to 47
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're on 32 bit, values that should be positive (unsigned) will be negative, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 32-bit, we won't enter this branch because of the 4 !== \PHP_INT_SIZE check above.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but values decoding to large values will be negative on 32 bit, no? Shouldn't we reject those?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I guess it's fine that way.


$this->value = $value;
Expand Down