Bug #72932 [NEW]: database sessions causes upload to CRASH if upload progress used
| From: | mark at sasoft dot co dot za | Date: | Tue, 23 Aug 2016 15:18:52 +0000 |
| Subject: | Bug #72932 [NEW]: database sessions causes upload to CRASH if upload progress used | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203518@lists.php.net to get a copy of this message | ||
From: mark at sasoft dot co dot za
Operating system: Windows
PHP version: Irrelevant
Package: Session related
Bug Type: Bug
Bug description:database sessions causes upload to CRASH if upload progress used
Description:
------------
It appears this bug exists regardless of any version of php or OS or web
server. I have physically tested this to occur across:
- Windows 7, Windows Server 2012 R2
- PHP Version 5.3, 5.4, 5.5, 5.6 and 7.0.10 (all binaries downloaded
from php.net windows already compiled as NTS x86 and x64)
- Apache 2.2 and IIS (7+8)
My php.ini has been modified only for session.save_handler = user. All
other settings left as default.
What happens is that if I submit a form with file upload progress
utilisation (ie. name as value from
ini_get("session.upload_progress.name")) then the upload actually
crashes the script and my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on
line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user
(path: C:\WINDOWS\Temp) in Unknown on line 0
It appears that php is trying to default back to use save_hander=files
and then fails. If i COMMENT OUT the PHP_SESSION_UPLOAD_PROGRESS line so
that file upload progress is disabled, it works perfectly. It also works
perfectly if i set the save_handler back to "files" in my php.ini.
Naturally, even if it didnt generate a fatal error, the file session
info would still be inaccessible to my database session if it succeeds
in writing to the file.
Test script:
---------------
The html form looks like this :
<iframe id="upload_iframe" name="upload_iframe" style="width: 1px;
height: 1px; display: block;border:0px;"></iframe>
<form id="myUploadForm" name="myUploadForm" target="upload_iframe"
action="uploadFile.php" method="post"
enctype="multipart/form-data">
<input type="hidden" name="UID" value="1">
<input type="hidden" value="myUploadForm"
name="PHP_SESSION_UPLOAD_PROGRESS">
<input type="file" class="upload" name="file"
id="file">
<input type="submit" class="cmi-button small white" value="Upload"
onclick="fileUpload.startUploadMonitoring();">
</form>
My session_set_save_handler override for _open looks like this :
function _open() {
if( ($this->dbc = mysqli_connect(DBSettings::HOSTNAME,
DBSettings::USERNAME, DBSettings::PASSWORD)) !== false ) {
$select_db = mysqli_select_db($this->dbc,
DBSettings::DATABASE_SHARED_SERVICES);
// $set_charset = mysqli_set_charset($this->dbc, DB_CHARSET);
return( $select_db /*&& $set_charset*/ );
}
else {
trigger_error(mysqli_error($this->dbc), E_USER_ERROR);
}
return( false );
}
(but i think the above handler override is irrelevant to this bug as
even if i change the trigger_error to return true rather, it makes no
difference as the error occurs BEFORE control is handed over to the USER
script)
Expected result:
----------------
it should firstly NOT crash PHP, and secondly it should use the php.ini
setting for my database session handler.
my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on
line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user
(path: C:\WINDOWS\Temp) in Unknown on line 0
Actual result:
--------------
my error log file contains the contents :
PHP Warning: Unknown: user session functions not defined in Unknown on
line 0
PHP Fatal error: Unknown: Failed to initialize storage module: user
(path: C:\WINDOWS\Temp) in Unknown on line 0
--
Edit bug report at https://bugs.php.net/bug.php?id=72932&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72932&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72932&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72932&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72932&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72932&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72932&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72932&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72932&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72932&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72932&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72932&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72932&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72932&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72932&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72932&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72932&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72932&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72932&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72932&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72932&r=mysqlcfg