php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #59163 wincache.namesalt > 9 characters corruption
Submitted: 2010-04-14 10:33 UTC Modified: 2010-04-14 19:59 UTC
From: RQuadling at GMail dot com Assigned: ruslany (profile)
Status: Closed Package: WinCache (PECL)
PHP Version: 5.3.2 OS: Windows XP SP3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: RQuadling at GMail dot com
New email:
PHP Version: OS:

 

 [2010-04-14 10:33 UTC] RQuadling at GMail dot com
Description:
------------
Setting wincache.namesalt to a string greater than 9 
characters, will be reported as a string with a null at 
offset 8.

e.g.

wincache.namesalt=PHP_WINCACHE

will be reported as ...


wincache.namesalt=PHP_WINC\000CHE

At the command prompt,

php --ri wincache

shows a space. phpinfo() shows nothing - PHP_WINCCHE.



Reproduce code:
---------------
php.exe -d wincache.namesalt=PHP_WINCACHE --ri wincache

Expected result:
----------------
wincache

Opcode cache => enabled
File cache => enabled
Version => 1.1.0412.0
Owner => iisphp@microsoft.com
Build Date => Apr 13 2010 17:38:02

Directive => Local Value => Master Value
wincache.fcenabled => On => On
wincache.ocenabled => On => On
wincache.enablecli => On => On
wincache.fcachesize => 128 => 128
wincache.ocachesize => 128 => 128
wincache.maxfilesize => 256 => 256
wincache.filecount => 4096 => 4096
wincache.chkinterval => 0 => 0
wincache.ttlmax => 1200 => 1200
wincache.debuglevel => 101 => 101
wincache.ignorelist => no value => no value
wincache.ocenabledfilter => no value => no value
wincache.fcenabledfilter => no value => no value
wincache.namesalt => PHP_WINCACHE => PHP_WINCACHE
wincache.localheap => 0 => 0
wincache.ucenabled => On => On
wincache.ucachesize => 8 => 8
wincache.scachesize => 8 => 8
wincache.rerouteini => no value => no value
wincache.fcndetect => On => On

Actual result:
--------------
wincache

Opcode cache => enabled
File cache => enabled
Version => 1.1.0412.0
Owner => iisphp@microsoft.com
Build Date => Apr 13 2010 17:38:02

Directive => Local Value => Master Value
wincache.fcenabled => On => On
wincache.ocenabled => On => On
wincache.enablecli => On => On
wincache.fcachesize => 128 => 128
wincache.ocachesize => 128 => 128
wincache.maxfilesize => 256 => 256
wincache.filecount => 4096 => 4096
wincache.chkinterval => 0 => 0
wincache.ttlmax => 1200 => 1200
wincache.debuglevel => 101 => 101
wincache.ignorelist => no value => no value
wincache.ocenabledfilter => no value => no value
wincache.fcenabledfilter => no value => no value
wincache.namesalt => PHP_WINC CHE => PHP_WINC CHE
wincache.localheap => 0 => 0
wincache.ucenabled => On => On
wincache.ucachesize => 8 => 8
wincache.scachesize => 8 => 8
wincache.rerouteini => no value => no value
wincache.fcndetect => On => On

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-14 11:23 UTC] don dot raman at microsoft dot com
Thank you a lot for finding and reporting this bug. It feels great to have community involvement here.

However this is not a code bug. The length of namesalt is restricted to 8 characters. But I see this is not documented anywhere. I will ask Ruslan to update the documentation with this information.

Ruslan, can you add this at http://us.php.net/manual/en/wincache.configuration.php#ini.wincache.namesalt.
 [2010-04-14 13:46 UTC] RQuadling at GMail dot com
The issue isn't that the namesalt is not documented to only allow 8 characters, the issue is the odd display when more 
than 9 characters are used.

PHP_WINCACHE becomes PHP_WINCCHE or PHP_WINC CHE depending upon what ui you are using (web or CLI).

Mmaybe, in php_wincache.c, the code ...

   /* Truncate namesalt to 8 characters */
   if(WCG(namesalt) != NULL && strlen(WCG(namesalt)) > NAMESALT_LENGTH_MAXIMUM)
   {
       *(WCG(namesalt) + NAMESALT_LENGTH_MAXIMUM) = 0;
   }

should also fill in the rest of the string.

   /* Truncate namesalt to 8 characters */
   if(WCG(namesalt) != NULL && strlen(WCG(namesalt)) > NAMESALT_LENGTH_MAXIMUM)
   {
       int saltLength = strlen(WCG(namesalt);
       while(saltLength > NAMESALT_LENGTH_MAXIMUM)
       {
           *(WCG(namesalt) + --saltLength) = 0;
       }
   }

That should stop the error I'm currently seeing.

Essentially, just documenting the limitation and having nothing to enforce it seems wrong.

If phpinfo is able to report the corrupted value, what else can use it incorrectly.

NOTE: wincache.php will also see PHP_WINCCHE, more than 8 characters.
 [2010-04-14 13:53 UTC] don dot raman at microsoft dot com
Yes, I didn't realize that. Thanks for the additional information. We will fix both the documentation as well as the code.
 [2010-04-14 19:59 UTC] ksingla at microsoft dot com
This bug has been fixed in SVN.

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.

Fixed.

http://svn.php.net/viewvc/pecl/wincache/trunk/php_wincache.c?r1=298013&r2=298012&pathrev=298013
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC