Skip to content

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Sep 18, 2017

Apparently, argon2_encodedlen() also counts the terminating NUL byte;
that doesn't appear to be documented somewhere, but from looking at the
implementation[1] it is pretty obvious. Therefore, the respective
zend_string has to be one byte shorter.

[1] https://github.com/P-H-C/phc-winner-argon2/blob/20161029/src/argon2.c#L431-L436

Apparently, `argon2_encodedlen()` also counts the terminating NUL byte;
that doesn't appear to be documented somewhere, but from looking at the
implementation[1] it is pretty obvious.  Therefore, the respective
`zend_string` has to be one byte shorter.

[1] <https://github.com/P-H-C/phc-winner-argon2/blob/20161029/src/argon2.c#L431-L436>
@cmb69
Copy link
Member Author

cmb69 commented Sep 18, 2017

Note that the implementation feels a bit hackish; using zend_string_truncate() might be preferable.

@krakjoe krakjoe added the Bug label Sep 27, 2017
@@ -538,7 +538,7 @@ PHP_FUNCTION(password_hash)
ZSTR_VAL(out),
ZSTR_LEN(out),
ZSTR_VAL(encoded),
ZSTR_LEN(encoded),
ZSTR_LEN(encoded) + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps could just put encoded_len here? But anyway seems you've nailed the case.

Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes, encoded_len appears to be better. Thanks. I'm going to apply the modified PR against PHP-7.2.

@php-pulls
Copy link

Comment on behalf of cmb at php.net:

Applied with 3f8961d

@php-pulls php-pulls closed this Oct 12, 2017
@cmb69 cmb69 deleted the bug75221 branch March 25, 2018 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants