php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60512
Patch prevent-segfault-with-user-or-pass-over-30chars revision 2011-12-13 16:22 UTC by paul dot visco at roswellpark dot org

Patch prevent-segfault-with-user-or-pass-over-30chars for PDO related Bug #60512

Patch version 2011-12-13 16:22 UTC

Return to Bug #60512 | Download this patch
Patch Revisions:

Developer: paul.visco@roswellpark.org

--- pdo_dblib.c	2011-12-12 21:52:42.163828653 -0500
+++ pdo_dblib_new.c	2011-12-12 21:54:23.690822485 -0500
@@ -93,46 +93,48 @@
 	char *state = "HY000";
 	TSRMLS_FETCH();
 
-	einfo = (pdo_dblib_err*)dbgetuserdata(dbproc);
-	if (!einfo) einfo = &DBLIB_G(err);
-
-	einfo->severity = severity;
-	einfo->oserr = oserr;
-	einfo->dberr = dberr;
-	if (einfo->oserrstr) {
-		efree(einfo->oserrstr);
-	}
-	if (einfo->dberrstr) {
-		efree(einfo->dberrstr);
-	}
-	if (oserrstr) {
-		einfo->oserrstr = estrdup(oserrstr);
-	} else {
-		einfo->oserrstr = NULL;
-	}
-	if (dberrstr) {
-		einfo->dberrstr = estrdup(dberrstr);
-	} else {
-		einfo->dberrstr = NULL;
-	}
-
-	switch (dberr) {
-		case SYBESEOF:
-		case SYBEFCON:	state = "01002"; break;
-		case SYBEMEM:	state = "HY001"; break;
-		case SYBEPWD:	state = "28000"; break;
-	}
-	strcpy(einfo->sqlstate, state);
-
-#if 0
+        if(dbproc != NULL){
+            einfo = (pdo_dblib_err*)dbgetuserdata(dbproc);
+            if (!einfo) einfo = &DBLIB_G(err);
+
+            einfo->severity = severity;
+            einfo->oserr = oserr;
+            einfo->dberr = dberr;
+            if (einfo->oserrstr) {
+                    efree(einfo->oserrstr);
+            }
+            if (einfo->dberrstr) {
+                    efree(einfo->dberrstr);
+            }
+            if (oserrstr) {
+                    einfo->oserrstr = estrdup(oserrstr);
+            } else {
+                    einfo->oserrstr = NULL;
+            }
+            if (dberrstr) {
+                    einfo->dberrstr = estrdup(dberrstr);
+            } else {
+                    einfo->dberrstr = NULL;
+            }
+
+            switch (dberr) {
+                    case SYBESEOF:
+                    case SYBEFCON:	state = "01002"; break;
+                    case SYBEMEM:	state = "HY001"; break;
+                    case SYBEPWD:	state = "28000"; break;
+            }
+            strcpy(einfo->sqlstate, state);
+        }
+        
 	php_error_docref(NULL TSRMLS_CC, E_WARNING,
 		"dblib error: %d %s (severity %d)",
 		dberr, dberrstr, severity);	
-#endif
+
 
 	return INT_CANCEL;
 }
 
+
 int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
 	int severity, char *msgtext, char *srvname, char *procname, DBUSMALLINT line)
 {
@@ -230,4 +232,4 @@
 		" DB-lib", "enabled");
 	php_info_print_table_row(2, "Flavour", PDO_DBLIB_FLAVOUR);
 	php_info_print_table_end();
-}
\ No newline at end of file
+}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 18:01:30 2024 UTC