php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7246 Using Sybase function(s) makes php to crash
Submitted: 2000-10-16 11:13 UTC Modified: 2001-05-28 06:53 UTC
From: toren at exense dot com Assigned:
Status: Closed Package: Sybase-ct (ctlib) related
PHP Version: 4.0.3pl1-4.0.5 OS: Win32
Private report: No CVE-ID: None
 [2000-10-16 11:13 UTC] toren at exense dot com
This script makes php crash, and it has been like this since version 4.0b4. I never tested it on version 3.

<?php

$db = sybase_pconnect("myserv", "myusr", "") ;
sybase_select_db("mydb",$db);
$result = sybase_query("SELECT col1, col2,..... FROM mytab",$db);

echo "<table border=1>\n";
echo "<tr><td>Code</td><td>Name</td>\n";

while ($myrow = sybase_fetch_row($result)) {
        printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[0],
$myrow[1], $myrow[2]);
}
sybase_close($db);
?>

If you run the php.exe you will get an exeption handle in the executable when sybase returnes, and if you run it as a moudle on Apache you just get a blank page.

If you set the min message level to 10 you will get the db message which says "changed db to....." before php dies.

My php.ini is the standard one with the php_sybase_ct.dll enabled.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-23 09:42 UTC] toren at exense dot com
It seems like the declaration of the "_client_message_handler" (line 201) and the
"_server_message_handler" (line 227) in "ext/sybase_ct/sybase_ct.c" are wrong.

According to the sybase sample code, found in "/sybase..../sample/exutils.h" they
are supposed to be declared not only as CS_RETCOD, but also as CS_PUBLIC.
This has also been mention by fabien@usa.net in bug report http://bugs.php.net/?id=8836

Which would make the statement on line 201 look like
   extern CS_RETCODE CS_PUBLIC _client_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_CLIENTMSG *errmsg)
instead of
   static CS_RETCODE _client_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_CLIENTMSG *errmsg)

and the statement on line 227 should look like
   extern CS_RETCODE CS_PUBLIC _server_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_SERVERMSG *srvmsg)
instead of
   static CS_RETCODE _server_message_handler(CS_CONTEXT *context, CS_CONNECTION *connection, CS_SERVERMSG *srvmsg)

I have tested this change on Windows NT/2000 and SuSE Linux without experiencing any problems.
Without the change php gives a memory fault on Windows NT/2000 after sybase_(p)connect if you are
using llibct.dll version 11.x.x. If you are using libct.dll version 10.04 it works ok, but this is a version sybase
is about to stop supporting.

TEN
 [2001-05-28 06:53 UTC] toren at exense dot com
Fixed in CVS. Fix will be in PHP 4.0.6

TEN
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 18 17:01:24 2021 UTC