-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
Bugfixes #1157
Bugfixes #1157
Conversation
PHPDOC fix
PHPDOC fixes
Fixed methods visibility
@@ -3086,7 +3086,7 @@ public function getSupportedVersions() | |||
* @return bool | |||
* @access private | |||
*/ | |||
private function disconnect_helper($reason) | |||
protected function disconnect_helper($reason) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SFTP class extends SSH2 and overrides method disconnect_helper($reason), also it calls parent's method:
protected function disconnect_helper($reason)
{
$this->pwd = false;
parent::disconnect_helper($reason);
}
Parent's method was declared as private, so could not be called outside the class.
I changed it's visibility to protected.
Also I have to change visibility of the successor's method.
@@ -652,7 +652,7 @@ class SSH2 | |||
* @see self::_get_channel_packet() | |||
* @access private | |||
*/ | |||
private $curTimeout; | |||
protected $curTimeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please minimize these changes to those that are required, since the phpdoc changes are bug fixes. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the only reason this is needed is because of the ASN1::decodeLength
. I did grep -r decodeLength .
and it looks like it's not actually being used. ASN1::encodeLength
is being used but not ASN1::decodeLength
.
It looks like decodeLength
ceased being used when I refactored the PKCS1/8 plugins in the master branch to facilitate re-use. At that point they used ASN1.php instead of having their own independent pseudo implementation of ASN1.
Overall, I'm thinking it'd probably just be better if decodeLength()
was deleted
@@ -2796,7 +2797,7 @@ public function setEndDate($date) | |||
*/ | |||
if (strtolower($date) == 'lifetime') { | |||
$temp = '99991231235959Z'; | |||
$temp = chr(ASN1::TYPE_GENERALIZED_TIME) . Functions::encodeLength(strlen($temp)) . $temp; | |||
$temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I'll have to add a unit test for this
phpseclib/File/X509.php
Outdated
{ | ||
return $this->getExtensionHelper($id, $cert); | ||
return $this->getExtensionHelper($id, $cert, $path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a unit test will need to be written for this too. This is only called with a third parameter by getRevokedCertificateExtension
.
getExtensions
(plural vs singular) probably ought to be updated similarly, as well, and then getRevokedCertificateExtensions
updated to call getExtensions
instead of getExtensionsHelper
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, spaces ought to be added before and after the =
in the $path=null
bit. PSR-1/2 do appear to discuss this but in areas where those standards do not provide clarity I'd say, as a general rule of thumb, the PEAR standards apply. Quoting https://pear.php.net/manual/en/standards.funcalls.php ,
As displayed above, there should be one space on either side of an equals sign used to assign the return value of a function to a variable.
idk how well the phpseclib codebase actually conforms to these standards but, anyway, I can take care of this when I merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the motivation behind this change?
edit: it doesn't seem like this comment is linked to the specific commit so I made a new comment from where the specific change I'm referring to is more clear.
@@ -80,7 +80,7 @@ public static function isValidEngine() | |||
* @param string $class | |||
* @return \phpseclib\Math\BigInteger\Engines\PHP | |||
*/ | |||
protected static function powModHelper(PHP $x, PHP $e, PHP $n, $class) | |||
public static function powModHelper(PHP $x, PHP $e, PHP $n, $class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the motivation behind this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File PHP.php
method:
protected function powModInner(PHP $e, PHP $n)
{
try {
$class = static::$modexpEngine;
return $class::powModHelper($this, $e, $n, static::class);
} catch (\Exception $err) {
return PHP\DefaultEngine::powModHelper($this, $e, $n, static::class);
}
}
As you can see here's a static call which can't be performed if the powModHelper method is not public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Engines/PHP/Base extends Engines/PHP so visibility shouldn't be an issue. Indeed, if visibility were an issue then one would think that changing the visibility from protected to private wouldn't break any unit tests but it does:
@@ -60,7 +60,7 @@ public static function isValidEngine() | |||
* @param string $class | |||
* @return \phpseclib\Math\BigInteger\Engines\BCMath | |||
*/ | |||
protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class) | |||
public static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made a similar change in f314f97#r131527744 . I don't understand the motivation for that change nor do I understand it for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File PHP.php
method:
protected function powModInner(PHP $e, PHP $n)
{
try {
$class = static::$modexpEngine;
return $class::powModHelper($this, $e, $n, static::class);
} catch (\Exception $err) {
return PHP\DefaultEngine::powModHelper($this, $e, $n, static::class);
}
}
As you can see here's a static call which can't be performed if the powModHelper method is not public
The changes look good to me! I guess I have a few things I need to do:
A few questions I have that it'd be cool if you could answer or do:
Thanks! |
phpseclib/File/X509.php
Outdated
* @access public | ||
* @return mixed | ||
*/ | ||
public function getExtension($id, $cert = null) | ||
public function getExtension($id, $cert = null, $path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should be $path = null
. As is not all the calls to getExtension
have a third parameter:
$issuerAltName = $this->getExtension('id-ce-subjectAltName', $issuer->currentCert);
Also, that's how it's defined with getExtensionHelper
:
private function getExtensionHelper($id, $cert = null, $path = null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind this - it looks like you fixed this specific issue with eb21fb2
The changes I mention that I'd do have been done here: https://github.com/terrafrost/phpseclib/tree/pre-1157-changes This branch has failing unit tests that you're changes should fix. Just LMK about the Thanks! |
Lots of PHPDOC fixes
Some method visibility fixes
Method signature fixes
And more