Re: Stricter error handling in mcrypt extension
| From: | Derick Rethans | Date: | Sun, 02 Mar 2014 17:07:34 +0000 |
| Subject: | Re: Stricter error handling in mcrypt extension | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72900@lists.php.net to get a copy of this message | ||
On Sun, 2 Mar 2014, Nikita Popov wrote:
> Hi internals!
>
> I would like to add a number of additional error checks in
> php_mcrypt_do_crypt - which affects the mcrypt_encrypt, mcrypt_decrypt and
> mcrypt_{BLOCK_CHAINING_MODE} userland functions.
>
> The proposed changes are:
> * Throw a warning and return bool(false) if the IV size is invalid. The
> old behavior was to throw a warning and use a NUL-byte IV.
> * Throw a warning and return bool(false) if no IV was specified, but the
> block chaining mode requires an IV. The old behavior was to throw a warning
> and use a NUL-byte IV.
> * Throw a warning and return bool(false) if the key size is invalid. The
> old behavior was to **silently** pad the string to the next valid key size
> with NUL bytes or, if the key is too long, to throw a warning and truncate
> it to the maximum valid key size.
>
> An implementation of these changes can be found in the PR
> https://github.com/php/php-src/pull/610.
I've added some comments, which those fixed, feel free to commit this.
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine