Skip to content

Commit

Permalink
- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIML…
Browse files Browse the repository at this point in the history
…OCK.

- fixed a couple inconsistencies in the docs.
- fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now.
- Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value.
  • Loading branch information
root committed Jan 20, 2020
1 parent 079d5b2 commit f7fd9ba
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Net/DNS2.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Net_DNS2
/*
* the current version of this library
*/
const VERSION = '1.4.4';
const VERSION = '1.4.5';

/*
* the default path to a resolv.conf file
Expand Down Expand Up @@ -734,7 +734,7 @@ public function signSIG0($filename)
/**
* a simple function to determine if the RR type is cacheable
*
* @param stream $_type the RR type string
* @param string $_type the RR type string
*
* @return bool returns true/false if the RR type if cachable
* @access public
Expand Down Expand Up @@ -878,7 +878,7 @@ public static function expandIPv6($_address)
* @param boolean $use_tcp true/false if the function should
* use TCP for the request
*
* @return mixed returns a Net_DNS2_Packet_Response object, or false on error
* @return Net_DNS2_Packet_Response
* @throws Net_DNS2_Exception
* @access protected
*
Expand Down
2 changes: 1 addition & 1 deletion Net/DNS2/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function set(Net_DNS2_Packet &$packet)
if ($packet->rdlength < Net_DNS2_Lookups::DNS_HEADER_SIZE) {

throw new Net_DNS2_Exception(
'invalid header data provided; to small',
'invalid header data provided; too small',
Net_DNS2_Lookups::E_HEADER_INVALID
);
}
Expand Down
14 changes: 12 additions & 2 deletions Net/DNS2/Lookups.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Net_DNS2_Lookups
const OPCODE_STATUS = 2; // RFC 1035
const OPCODE_NOTIFY = 4; // RFC 1996
const OPCODE_UPDATE = 5; // RFC 2136
const OPCODE_DSO = 6; // RFC 8490

/*
* Resource Record Classes
Expand All @@ -127,8 +128,9 @@ class Net_DNS2_Lookups
const RCODE_NXRRSET = 8; // RFC 2136
const RCODE_NOTAUTH = 9; // RFC 2136
const RCODE_NOTZONE = 10; // RFC 2136
const RCODE_DSOTYPENI = 11; // RFC 8490

// 11-15 reserved
// 12-15 unassigned

const RCODE_BADSIG = 16; // RFC 2845
const RCODE_BADVERS = 16; // RFC 6891
Expand Down Expand Up @@ -207,6 +209,11 @@ class Net_DNS2_Lookups
const EDNS0_OPT_PADDING = 12;
const EDNS0_OPT_CHAIN = 13;
const EDNS0_OPT_KEY_TAG = 14;
// 15 - unsassigned
const EDNS0_OPT_CLIENT_TAG = 16;
const EDNS0_OPT_SERVER_TAG = 17;
// 18-26945 - unassigned
const EDNS0_OPT_DEVICEID = 26946;

/*
* DNSSEC Algorithms
Expand Down Expand Up @@ -312,8 +319,9 @@ class Net_DNS2_Lookups
'CDNSKEY' => 60, // RFC 7344
'OPENPGPKEY' => 61, // RFC 7929
'CSYNC' => 62, // RFC 7477
'ZONEMD' => 63, // Not implemented yet

// 63 - 98 unassigned
// 64 - 98 unassigned

'SPF' => 99, // RFC 4408
'UINFO' => 100, // no RFC, Not implemented
Expand All @@ -339,6 +347,8 @@ class Net_DNS2_Lookups
'URI' => 256, // tools.ietf.org/html/draft-faltstrom-uri-06
'CAA' => 257, // tools.ietf.org/html/draft-ietf-pkix-caa-03
'AVC' => 258, // Application Visibility and Control
'DOA' => 259, // Not implemented yet
'AMTRELAY' => 260, // Not implemented yet

// 259 - 32767 unassigned

Expand Down
4 changes: 2 additions & 2 deletions Net/DNS2/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Net_DNS2_PrivateKey
public $algorithm;

/*
* the key format fo the signature
* the key format of the signature
*/
public $key_format;

Expand Down Expand Up @@ -257,7 +257,7 @@ public function parseFile($file)
switch(strtolower($key)) {

case 'private-key-format':
$this->_key_format = $value;
$this->key_format = $value;
break;

case 'algorithm':
Expand Down
4 changes: 2 additions & 2 deletions Net/DNS2/RR/NIMLOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/

/**
* NIMLOCK Resource Record - undefined; the rdata is simply used as-is in it's
* NIMLOC Resource Record - undefined; the rdata is simply used as-is in it's
* binary format, so not process has to be done.
*
* @category Networking
Expand All @@ -61,7 +61,7 @@
* @see Net_DNS2_RR
*
*/
class Net_DNS2_RR_NIMLOCK extends Net_DNS2_RR
class Net_DNS2_RR_NIMLOC extends Net_DNS2_RR
{
/**
* method to return the rdata portion of the packet as a string
Expand Down
2 changes: 1 addition & 1 deletion Net/DNS2/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(array $options = null)
* @param string $type the name of the RR type to lookup
* @param string $class the name of the RR class to lookup
*
* @return Net_DNS2_RR object
* @return Net_DNS2_Packet_Response object
* @throws Net_DNS2_Exception
* @access public
*
Expand Down
12 changes: 11 additions & 1 deletion Net/DNS2/Socket/Sockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ public function read(&$size, $max_size)
return false;
}

//
// If an error occurs, if the connection is reset, or if no data is
// available, buf will be set to NULL.
//
if (is_null($data) == true)
{
$this->last_error = socket_strerror(socket_last_error());
return false;
}

$length = ord($data[0]) << 8 | ord($data[1]);
if ($length < Net_DNS2_Lookups::DNS_HEADER_SIZE) {

Expand Down Expand Up @@ -333,7 +343,7 @@ public function read(&$size, $max_size)
while (1) {

$chunk_size = @socket_recv($this->sock, $chunk, $length, MSG_WAITALL);
if ($chunk_size === false) {
if ( ($chunk_size === false) || (is_null($chunk) == true) ) {

$size = $chunk_size;
$this->last_error = socket_strerror(socket_last_error());
Expand Down
13 changes: 6 additions & 7 deletions package.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@
$pkg->setSummary('PHP5 Resolver library used to communicate with a DNS server.');
$pkg->setDescription("Provides (roughly) the same functionality as Net_DNS, but using PHP5 objects, exceptions for error handling, better sockets support.\n\nThis release is (in most cases) 2x - 10x faster than Net_DNS, as well as includes more RR's (including DNSSEC RR's), and improved sockets and streams support.");
$pkg->setChannel('pear.php.net');
$pkg->setAPIVersion('1.4.4');
$pkg->setReleaseVersion('1.4.4');
$pkg->setAPIVersion('1.4.5');
$pkg->setReleaseVersion('1.4.5');
$pkg->setReleaseStability('stable');
$pkg->setAPIStability('stable');
$pkg->setNotes(
"- bugfix when returning an empty bitmap-type in BitMap.php - patch from BugMaster510945.\n" .
"- added the BIND 9 private record RR (TYPE65534) - patch from BugMaster510945.\n" .
"- added DNSSEC algorithms 13-16 (ECDSAP256SHA256, ECDSAP384SHA384, ED25519, and ED448).\n" .
"- added SSHFP algoritm ED25519.\n" .
"- modified Net_DNS2::sendPacket() to use current()/next() rather than the deprecated each() (deprecated in 7.2).\n"
"- the Net_DNS2_RR_NIMLOC class was incorrectly named Net_DNS2_RR_NIMLOCK.\n" .
"- fixed a couple inconsistencies in the docs.\n" .
"- fixed a PHP 7.4 bug in Sockets.php; accessing a null value as an array throws an exception now.\n" .
"- Net_DNS2_PrivateKey was using the wrong member variable name for the key_format value.\n"
);
$pkg->setPackageType('php');
$pkg->addRelease();
Expand Down

0 comments on commit f7fd9ba

Please sign in to comment.