#49767 [Asn->Csd]: estrdup crash
| From: | stas@php.net | Date: | Fri, 16 Oct 2009 23:33:51 +0000 |
| Subject: | #49767 [Asn->Csd]: estrdup crash | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143647@lists.php.net to get a copy of this message | ||
ID: 49767
Updated by: stas@php.net
Reported By: mb at smartftp dot com
-Status: Assigned
+Status: Closed
Bug Type: Reproducible crash
Operating System: win32 only -Windows 2008 SP2 x86
PHP Version: 5.3.0
Assigned To: pajoye
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
This should be fixed now.
Previous Comments:
------------------------------------------------------------------------
[2009-10-13 22:25:45] danielc@php.net
Bug #47627 marked duplicate of this.
------------------------------------------------------------------------
[2009-10-04 19:35:54] mb at smartftp dot com
I have also sent you the crash report by email. Open the .mht file (RS
removed the .mth extension for some reason) with IE.
------------------------------------------------------------------------
[2009-10-04 19:25:46] pajoye@php.net
I corrected myself about the script by asking for the full bt (the one
on RS was not readable).
The diagnostic sounds good, I have to reproduce it to be sure. Assigned
to me.
------------------------------------------------------------------------
[2009-10-04 17:28:20] mb at smartftp dot com
I don't think you need a script. A little bit of time and motivation
would do as well:
Please review your code:
File: main.c
PHPAPI int php_execute_script(zend_file_handle *primary_file
TSRMLS_DC)
{
...
#ifdef PHP_WIN32
UpdateIniFromRegistry(primary_file->filename TSRMLS_CC);
#endif
..
}
Then:
File: registry.c
void UpdateIniFromRegistry(char *path TSRMLS_DC)
{
-> BUG: missing check for argument
// here comes the check for Per Directory registry value. If it is not
found the function exists and never comes to the estrdup and hence no
crash.
...
orig_path = path = estrdup(path);
..
}
The problem only happens if the "Per Directory Values" registry key is
present. In this case estrdup(NULL) is called and you get the crash.
So I think the argument (path) should be checked for NULL. And when I
look at the main.c I also noticed that you sometimes expect the
primary_file->filename to be null, so maybe you add a check before the
UpdateIniFromRegistry() call.
Proposed FIX:
#ifdef PHP_WIN32
if(primary_file->filename)
{
UpdateIniFromRegistry(primary_file->filename TSRMLS_CC);
}
#endif
+ Add argument check for UpdateIniFromRegistry
Workaround:
Remove "Per Directories Values" registry key.
Regards,
Mat
------------------------------------------------------------------------
[2009-10-04 17:23:34] pajoye@php.net
Btw, can you also zip the report and send it to me or provide a link to
the zip (pls not one of these radidshare thing) :)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/49767
--
Edit this bug report at http://bugs.php.net/?id=49767&edit=1