Bug #54935 [NEW]: php_win_err can lead to crash

From: Date: Thu, 26 May 2011 12:32:07 +0000
Subject: Bug #54935 [NEW]: php_win_err can lead to crash
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160971@lists.php.net to get a copy of this message
From:             
Operating system: Windows
PHP version:      5.3.6
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:php_win_err can lead to crash

Description:
------------
Under Windows if php fail to load an extension apache crash.

Looking at code I discovered that php_win_err is wrong (I don't know if
this fix my problem).

In win32/winutil.c

PHPAPI char *php_win_err(int error)
{
        char *buf = NULL;

        FormatMessage(
                FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
|   FORMAT_MESSAGE_IGNORE_INSERTS,
                NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&buf, 0, NULL
        );

        return (buf ? (char *) buf : "");
}

now if FormatMessage fails buf is NULL and a "" is returned however in
ext/standard/dl.c a LocalFree is called if err (php_win_err result) is not
NULL.

Expected result:
----------------
Program should report error and not crash


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54935&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=54935&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=54935&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=54935&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=54935&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54935&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=54935&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=54935&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=54935&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=54935&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=54935&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=54935&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=54935&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=54935&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=54935&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54935&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54935&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=54935&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=54935&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=54935&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=54935&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=54935&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#160971) next »