php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7632 Segmentation fault upon call to sybase_connect()
Submitted: 2000-11-03 18:50 UTC Modified: 2000-11-07 12:49 UTC
From: serge at panix dot com Assigned:
Status: Closed Package: Sybase (dblib) related
PHP Version: 4.0.3pl1 OS: Solaris 8
Private report: No CVE-ID: None
 [2000-11-03 18:50 UTC] serge at panix dot com
Setup:

  Host: Sun SparcServer 20 w/128Mb RAM, one CPU
  O/S: Solaris 8
  GCC: 2.95.2
  GDB: 5.0
  PHP: 4.0.3pl1
  PHP Config Args: now lost after a few changes (sorry), but definetely had these:
    --with-sybase=<path to sybase> --with-xml --enable-track-vars

Problem:

The following PHP script:

<?php
        global $s_connection;

        $s_connection = sybase_connect ( "SYBSRV", "user", "password" )
                or die("Could not make SYBASE connection");

        echo "<b>Connected</b>";

        sybase_close($s_connection);
?>

invoked as

        /usr/local/bin/php <path to script>/test.php

always resulted in a "Segmentation fault (core dumped)."  GDB stack trace showed the following:

(gdb) bt
#0  0xef132b9c in strlen () from /usr/lib/libc.so.1
#1  0xef547ae8 in dbsetlname () from /usr/local/app/sybase/lib/libsybdb.so
#2  0x8838c in php_sybase_do_connect (ht=3, return_value=0x145d58,
    this_ptr=0x0, return_value_used=1, persistent=0) at php_sybase_db.c:354
#3  0x888c8 in php_if_sybase_connect (ht=3, return_value=0x145d58,
    this_ptr=0x0, return_value_used=1) at php_sybase_db.c:512
#4  0xd3038 in execute ()
#5  0xa1fe4 in zend_execute_scripts (type=8, file_count=3) at zend.c:717
#6  0x26f70 in php_execute_script (primary_file=0xeffffb88) at main.c:1200
#7  0x24ebc in main (argc=2, argv=0xeffffc14) at cgi_main.c:715
(gdb)

Stepping through ext/sybase/php_sybase_db.c:php_sybase_do_connect() with gdb showed that the segmentation fault occured at line 354

353:        if (charset) {
354:                DBSETLCHARSET(sybase.login,charset);
355:        }

and was caused by the uninitialized `charset' which contained an out-of-range address.  Changing the declaration of charset at line 257 from

        char *user,*passwd,*host,*charset;

to

        char *user,*passwd,*host,*charset=(char *)0;

and recompililng php seemed to alleviate the problem.

Thanks for looking into this,
Sergey

P.S. php_sybase_db.c's ident was
  /* $Id: php_sybase_db.c,v 1.4 2000/09/03 17:43:09 derick Exp $ */

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-07 12:49 UTC] joey@php.net
Thanks for your report. This has actually been fixed in CVS
for quite some time.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 30 22:01:28 2024 UTC