Re: [PHP-CVS] com php-src: Fix bug #61660: bin2hex(hex2bin($data)) != $data: NEWS ext/standard/string.c ext/standard/tests/strings/bug61660.phpt

2012-04-09 Thread Ferenc Kovacs
>
>
> I didn't follow the IRC discussion on this, but why are we now
> discriminating against odd length values?  There is nothing in the doc
> to indicate they can't be used, so this might cause some breakage for
> what gain?  From a purely mathematical standpoint 'A' (for example) is
> a hexadecimal number of odd length.  Why can't this be accepted?
>
> Chris
>
>
hi Chris,

did you read up the comments on the bug?

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Re: [PHP-CVS] com php-src: Fix bug #61660: bin2hex(hex2bin($data)) != $data: NEWS ext/standard/string.c ext/standard/tests/strings/bug61660.phpt

2012-04-09 Thread Christopher Jones




On 04/08/2012 01:36 PM, Nikita Popov wrote:

Fix bug #61660: bin2hex(hex2bin($data)) != $data

If the input data has an odd length a warning is thrown and false is returned.




+++ b/ext/standard/tests/strings/bug61660.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #61660: bin2hex(hex2bin($data)) != $data
+--FILE--
+
+--EXPECTF--
+Warning: hex2bin(): Hexadecimal input string must have an even length in %s on 
line %d
+bool(false)




I didn't follow the IRC discussion on this, but why are we now
discriminating against odd length values?  There is nothing in the doc
to indicate they can't be used, so this might cause some breakage for
what gain?  From a purely mathematical standpoint 'A' (for example) is
a hexadecimal number of odd length.  Why can't this be accepted?

Chris

--
Email: christopher.jo...@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fix bug #61660: bin2hex(hex2bin($data)) != $data: NEWS ext/standard/string.c ext/standard/tests/strings/bug61660.phpt

2012-04-08 Thread Laruence
On Mon, Apr 9, 2012 at 4:36 AM, Nikita Popov  wrote:
> Commit:    7ae93a2c4c8a51cc2aec9977ce3c83c100e382a0
> Author:    Nikita Popov          Sun, 8 Apr 2012 22:36:50 +0200
> Parents:   f7d407678570f8e4063b70bd30f3fc19c10442ea
> Branches:  PHP-5.4 master
>
> Link:       
> http://git.php.net/?p=php-src.git;a=commitdiff;h=7ae93a2c4c8a51cc2aec9977ce3c83c100e382a0
>
> Log:
> Fix bug #61660: bin2hex(hex2bin($data)) != $data
>
> If the input data has an odd length a warning is thrown and false is returned.
>
> Bugs:
> https://bugs.php.net/61660
>
> Changed paths:
>  M  NEWS
>  M  ext/standard/string.c
>  A  ext/standard/tests/strings/bug61660.phpt
>
>
> Diff:
> diff --git a/NEWS b/NEWS
> index 7b80084..42f7cd9 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,7 @@ PHP                                                           
>              NEWS
>   . "Connection: close" instead of "Connection: closed" (Gustavo)
>
>  - Core:
> +  . Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov)
>   . Fixed bug #61650 (ini parser crashes when using ${} ini variables
>     (without apache2)). (Laruence)
>   . Fixed bug #61605 (header_remove() does not remove all headers). (Laruence)
> diff --git a/ext/standard/string.c b/ext/standard/string.c
> index 0aade78..5c33232 100644
> --- a/ext/standard/string.c
> +++ b/ext/standard/string.c
> @@ -266,6 +266,11 @@ PHP_FUNCTION(hex2bin)
>                return;
>        }
>
> +       if (datalen % 2 != 0) {
Hi:
I prefer to use datalen & 1, but up to you  :)

thanks
> +               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Hexadecimal 
> input string must have an even length");
> +               RETURN_FALSE;
> +       }
> +
>        result = php_hex2bin((unsigned char *)data, datalen, &newlen);
>
>        if (!result) {
> diff --git a/ext/standard/tests/strings/bug61660.phpt 
> b/ext/standard/tests/strings/bug61660.phpt
> new file mode 100644
> index 000..010ea47
> --- /dev/null
> +++ b/ext/standard/tests/strings/bug61660.phpt
> @@ -0,0 +1,11 @@
> +--TEST--
> +Bug #61660: bin2hex(hex2bin($data)) != $data
> +--FILE--
> + +
> +var_dump(hex2bin('123'));
> +
> +?>
> +--EXPECTF--
> +Warning: hex2bin(): Hexadecimal input string must have an even length in %s 
> on line %d
> +bool(false)
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] com php-src: Fix bug #61660: bin2hex(hex2bin($data)) != $data: NEWS ext/standard/string.c ext/standard/tests/strings/bug61660.phpt

2012-04-08 Thread Pierre Joye
hi!

UPGRADING note too please :)

Cheers,

On Sun, Apr 8, 2012 at 10:36 PM, Nikita Popov  wrote:
> Commit:    7ae93a2c4c8a51cc2aec9977ce3c83c100e382a0
> Author:    Nikita Popov          Sun, 8 Apr 2012 22:36:50 +0200
> Parents:   f7d407678570f8e4063b70bd30f3fc19c10442ea
> Branches:  PHP-5.4 master
>
> Link:       
> http://git.php.net/?p=php-src.git;a=commitdiff;h=7ae93a2c4c8a51cc2aec9977ce3c83c100e382a0
>
> Log:
> Fix bug #61660: bin2hex(hex2bin($data)) != $data
>
> If the input data has an odd length a warning is thrown and false is returned.
>
> Bugs:
> https://bugs.php.net/61660
>
> Changed paths:
>  M  NEWS
>  M  ext/standard/string.c
>  A  ext/standard/tests/strings/bug61660.phpt
>
>
> Diff:
> diff --git a/NEWS b/NEWS
> index 7b80084..42f7cd9 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,7 @@ PHP                                                           
>              NEWS
>   . "Connection: close" instead of "Connection: closed" (Gustavo)
>
>  - Core:
> +  . Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov)
>   . Fixed bug #61650 (ini parser crashes when using ${} ini variables
>     (without apache2)). (Laruence)
>   . Fixed bug #61605 (header_remove() does not remove all headers). (Laruence)
> diff --git a/ext/standard/string.c b/ext/standard/string.c
> index 0aade78..5c33232 100644
> --- a/ext/standard/string.c
> +++ b/ext/standard/string.c
> @@ -266,6 +266,11 @@ PHP_FUNCTION(hex2bin)
>                return;
>        }
>
> +       if (datalen % 2 != 0) {
> +               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Hexadecimal 
> input string must have an even length");
> +               RETURN_FALSE;
> +       }
> +
>        result = php_hex2bin((unsigned char *)data, datalen, &newlen);
>
>        if (!result) {
> diff --git a/ext/standard/tests/strings/bug61660.phpt 
> b/ext/standard/tests/strings/bug61660.phpt
> new file mode 100644
> index 000..010ea47
> --- /dev/null
> +++ b/ext/standard/tests/strings/bug61660.phpt
> @@ -0,0 +1,11 @@
> +--TEST--
> +Bug #61660: bin2hex(hex2bin($data)) != $data
> +--FILE--
> + +
> +var_dump(hex2bin('123'));
> +
> +?>
> +--EXPECTF--
> +Warning: hex2bin(): Hexadecimal input string must have an even length in %s 
> on line %d
> +bool(false)
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php