php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58004 Breaks UTF-8 in keys
Submitted: 2008-01-11 14:48 UTC Modified: 2008-01-11 16:34 UTC
From: nick at reloco dot com dot ar Assigned:
Status: Closed Package: memcache (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2008-01-11 14:48 UTC] nick at reloco dot com dot ar
Description:
------------
It's converting bytes with the 7th bit on to underscores, this breaks UTF-8. The cuplrit is mmc_prepare_key_ex(). This function does:

        for (i=0; i<*result_len; i++) {
                result[i] = key[i] > ' ' ? key[i] : '_';
        }

... to remove control characters, but as chars are signed... those with the high bit on will be negative!

The fix is to manually cast this to unsigned char before the comparison:

        for (i=0; i<*result_len; i++) {
                result[i] = ((unsigned char)key[i]) > ' ' ? key[i] : '_';
        }

Thanks!



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-11 16:34 UTC] mikael at synd dot info
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu May 06 06:01:24 2021 UTC