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

From: Date: Sun, 08 Apr 2012 20:52:19 +0000
Subject: Re: com php-src: Fix bug #61660: bin2hex(hex2bin($data)) != $data: NEWS ext/standard/string.c ext/standard/tests/strings/bug61660.phpt
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-68694@lists.php.net to get a copy of this message
hi! UPGRADING note too please :) Cheers, On Sun, Apr 8, 2012 at 10:36 PM, Nikita Popov <nikic@php.net> wrote: > Commit:    7ae93a2c4c8a51cc2aec9977ce3c83c100e382a0 > Author:    Nikita Popov <nikic@php.net>         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 ${xxxx} 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 0000000..010ea47 > --- /dev/null > +++ b/ext/standard/tests/strings/bug61660.phpt > @@ -0,0 +1,11 @@ > +--TEST-- > +Bug #61660: bin2hex(hex2bin($data)) != $data > +--FILE-- > +<?php > + > +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

« previous php.cvs (#68694) next »