Skip to content

Commit

Permalink
Fix param types for mcrypt_get_block_size() to match PHP
Browse files Browse the repository at this point in the history
Reviewed By: edwinsmith

Differential Revision: D3447281

fbshipit-source-id: a88549307faad886f5a0f78d421aa28e08d21b1c
  • Loading branch information
mxw authored and Hhvm Bot committed Jul 1, 2016
1 parent 6d4cf88 commit 39e7e17
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hphp/runtime/ext/mcrypt/ext_mcrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@ Variant HHVM_FUNCTION(mcrypt_ofb, const String& cipher, const String& key,
}

Variant HHVM_FUNCTION(mcrypt_get_block_size, const String& cipher,
const Variant& module /* = null_string */) {
const String& mode) {
MCRYPT td = mcrypt_module_open((char*)cipher.data(),
(char*)MCG(algorithms_dir).data(),
(char*)module.asCStrRef().data(),
(char*)mode.data(),
(char*)MCG(modes_dir).data());
if (td == MCRYPT_FAILED) {
MCRYPT_OPEN_MODULE_FAILED("mcrypt_get_block_size");
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/ext/mcrypt/ext_mcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function mcrypt_generic(resource $td,
*/
<<__Native>>
function mcrypt_get_block_size(string $cipher,
?string $mode = null): mixed;
string $mode): mixed;

/**
* Gets the name of the specified cipher
Expand Down
1 change: 1 addition & 0 deletions hphp/test/slow/ext_mcrypt/ext_mcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function VERIFY($x) { VS($x != false, true); }
//////////////////////////////////////////////////////////////////////

VS(mcrypt_get_block_size("tripledes", "ecb"), 8);
mcrypt_get_block_size("tripledes");
VS(mcrypt_get_cipher_name(MCRYPT_TRIPLEDES), "3DES");
VS(mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB), 16);
VS(mcrypt_get_iv_size("des", "ecb"), 8);
Expand Down
2 changes: 2 additions & 0 deletions hphp/test/slow/ext_mcrypt/ext_mcrypt.php.expectf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Deprecated: Function mcrypt_ofb() is deprecated in %s/test/slow/ext_mcrypt/ext_m
bool(true)
bool(true)
bool(true)

Warning: mcrypt_get_block_size() expects exactly 2 parameters, 1 given in %s/test/slow/ext_mcrypt/ext_mcrypt.php on line 109
bool(true)
bool(true)
bool(true)
Expand Down

0 comments on commit 39e7e17

Please sign in to comment.