php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22709 Sometime crash when database unavailable
Submitted: 2003-03-14 13:40 UTC Modified: 2003-03-15 18:45 UTC
From: Vladimir dot Michl at seznam dot cz Assigned:
Status: Closed Package: InterBase related
PHP Version: 4.2.3 OS: Any
Private report: No CVE-ID:
 [2003-03-14 13:40 UTC] Vladimir dot Michl at seznam dot cz
PHP sometime crash, when interbase database go to unavailable during script execution.

Problem is, when get_link_trans return NULL in ib_link.

I localise problem and here is fix (fixed in _php_ibase_def_trans and _php_ibase_trans_end):

*** interbase.c.orig	Fri Mar 14 14:11:51 2003
--- interbase.c	Fri Mar 14 14:21:47 2003
***************
*** 1572,1578 ****
  {
  	TSRMLS_FETCH();
  	
! 	if (trans_n == 0 && ib_link->trans[0] == NULL) { 
  		if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) {
  			_php_ibase_error();
  			return FAILURE;
--- 1572,1582 ----
  {
  	TSRMLS_FETCH();
  	
!         if (ib_link == NULL){
! 	        php_error(E_WARNING, "Database link is not valid");
! 	        return FAILURE;
! 	};
!         if (trans_n == 0 && ib_link->trans[0] == NULL) { 
  		if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) {
  			_php_ibase_error();
  			return FAILURE;
***************
*** 1609,1614 ****
--- 1613,1622 ----
  			break;
  	}
  
+ 	if (ib_link == NULL) {
+ 		php_error(E_WARNING, "Database link is not valid");
+ 		RETURN_FALSE;
+ 	}
  	if (ib_link->trans[trans_n] == NULL) {
  		php_error(E_WARNING, "Trying to commit or rollback an already handled transaction");
  		RETURN_FALSE;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-14 19:27 UTC] sniper@php.net
Are you really using 4.3.2RC1? Where did you get it? :)
In any case, please provide any patches in the unified diff
format. ( diff -u )

 [2003-03-15 14:22 UTC] Vladimir dot Michl at seznam dot cz
Really, I test it on 4.2.3 but if I see to CVS, to interbase.c, this bug is not fixed. I discover this bug in php 4.1.1, but now I have time to locate problem.

I have experience, that PHP team if see too old version
of PHP that reject patch. Patch may fix some problem, not fixed in actual version, but too old version of PHP -> reject patch.

See to source: get_link_trans may return NULL in ib_link, but code after call get_link_trans not handle this situation.

Here is path in unified diff:

--- interbase.c.orig    Fri Mar 14 14:11:51 2003
+++ interbase.c Fri Mar 14 14:21:47 2003
@@ -1572,7 +1572,11 @@
 {
        TSRMLS_FETCH();
        
-       if (trans_n == 0 && ib_link->trans[0] == NULL) { 
+        if (ib_link == NULL){
+               php_error(E_WARNING, "Database link is not valid");
+               return FAILURE;
+       };
+        if (trans_n == 0 && ib_link->trans[0] == NULL) { 
                if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) {
                        _php_ibase_error();
                        return FAILURE;
@@ -1609,6 +1613,10 @@
                        break;
        }
 
+       if (ib_link == NULL) {
+               php_error(E_WARNING, "Database link is not valid");
+               RETURN_FALSE;
+       }
        if (ib_link->trans[trans_n] == NULL) {
                php_error(E_WARNING, "Trying to commit or rollback an already handled transaction");
                RETURN_FALSE;
 [2003-03-15 18:45 UTC] sniper@php.net
Slightly modified patch committed. (just some coding style changes :)

 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 14:02:18 2014 UTC