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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nick at reloco dot com dot ar
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC