summaryrefslogtreecommitdiff
path: root/ext/odbc
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:27 -0400
commit2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch)
tree41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /ext/odbc
parentd29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff)
downloadphp-upstream/5.2.2.tar.gz
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'ext/odbc')
-rw-r--r--ext/odbc/birdstep.c4
-rw-r--r--ext/odbc/php_birdstep.h4
-rw-r--r--ext/odbc/php_odbc.c48
-rw-r--r--ext/odbc/php_odbc.h4
-rw-r--r--ext/odbc/php_odbc_includes.h5
5 files changed, 32 insertions, 33 deletions
diff --git a/ext/odbc/birdstep.c b/ext/odbc/birdstep.c
index 60e76cd56..053bf180e 100644
--- a/ext/odbc/birdstep.c
+++ b/ext/odbc/birdstep.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: birdstep.c,v 1.13.2.2 2006/01/01 12:50:10 sniper Exp $ */
+/* $Id: birdstep.c,v 1.13.2.2.2.1 2007/01/01 09:36:03 sebastian Exp $ */
/*
* TODO:
diff --git a/ext/odbc/php_birdstep.h b/ext/odbc/php_birdstep.h
index b7180ec0e..9450dc19f 100644
--- a/ext/odbc/php_birdstep.h
+++ b/ext/odbc/php_birdstep.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_birdstep.h,v 1.5.2.1 2006/01/01 12:50:10 sniper Exp $ */
+/* $Id: php_birdstep.h,v 1.5.2.1.2.1 2007/01/01 09:36:03 sebastian Exp $ */
#ifndef PHP_BIRDSTEP_H
#define PHP_BIRDSTEP_H
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index b843b3da0..c473f7cde 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc.c,v 1.189.2.4.2.1 2006/06/15 18:33:08 dmitry Exp $ */
+/* $Id: php_odbc.c,v 1.189.2.4.2.7 2007/03/13 00:04:38 stas Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -544,9 +544,9 @@ PHP_MINFO_FUNCTION(odbc)
php_info_print_table_start();
php_info_print_table_header(2, "ODBC Support", "enabled");
- sprintf(buf, "%ld", ODBCG(num_persistent));
+ snprintf(buf, sizeof(buf), "%ld", ODBCG(num_persistent));
php_info_print_table_row(2, "Active Persistent Links", buf);
- sprintf(buf, "%ld", ODBCG(num_links));
+ snprintf(buf, sizeof(buf), "%ld", ODBCG(num_links));
php_info_print_table_row(2, "Active Links", buf);
php_info_print_table_row(2, "ODBC library", PHP_ODBC_TYPE);
#ifndef PHP_WIN32
@@ -587,6 +587,10 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
do {
*/
rc = SQLError(henv, conn, stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize);
+ if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
+ snprintf(state, sizeof(state), "HY000");
+ snprintf(errormsg, sizeof(errormsg), "Failed to fetch error message");
+ }
if (conn_resource) {
memcpy(conn_resource->laststate, state, sizeof(state));
memcpy(conn_resource->lasterrormsg, errormsg, sizeof(errormsg));
@@ -911,11 +915,10 @@ PHP_FUNCTION(odbc_prepare)
} else {
result->values = NULL;
}
- result->id = zend_list_insert(result, le_result);
zend_list_addref(conn->id);
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RESOURCE(result->id);
+ ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -1158,7 +1161,7 @@ PHP_FUNCTION(odbc_cursor)
result->stmt, state, &error, errormsg,
sizeof(errormsg)-1, &errormsgsize);
if (!strncmp(state,"S1015",5)) {
- sprintf(cursorname,"php_curs_%d", (int)result->stmt);
+ snprintf(cursorname, max_len+1, "php_curs_%d", (int)result->stmt);
if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) {
odbc_sql_error(result->conn_ptr, result->stmt, "SQLSetCursorName");
RETVAL_FALSE;
@@ -1224,7 +1227,7 @@ PHP_FUNCTION(odbc_data_source)
if (rc != SQL_SUCCESS) {
/* ummm.... he did it */
- odbc_sql_error(conn, NULL, "SQLDataSources");
+ odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLDataSources");
RETURN_FALSE;
}
@@ -1331,12 +1334,10 @@ PHP_FUNCTION(odbc_exec)
} else {
result->values = NULL;
}
- result->id = zend_list_insert(result, le_result);
zend_list_addref(conn->id);
result->conn_ptr = conn;
result->fetched = 0;
-
- RETURN_RESOURCE(result->id);
+ ZEND_REGISTER_RESOURCE(return_value, result, le_result);
}
/* }}} */
@@ -1984,12 +1985,12 @@ PHP_FUNCTION(odbc_result_all)
RETURN_FALSE;
}
if (rc == SQL_SUCCESS_WITH_INFO)
- php_printf(buf,result->longreadlen);
+ PHPWRITE(buf, result->longreadlen);
else if (result->values[i].vallen == SQL_NULL_DATA) {
php_printf("<td>NULL</td>");
break;
} else {
- php_printf(buf, result->values[i].vallen);
+ PHPWRITE(buf, result->values[i].vallen);
}
php_printf("</td>");
break;
@@ -2040,7 +2041,7 @@ PHP_FUNCTION(odbc_free_result)
result->values = NULL;
}
- zend_list_delete(result->id);
+ zend_list_delete(Z_LVAL_PP(pv_res));
RETURN_TRUE;
}
@@ -2090,23 +2091,23 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
if (strstr(db, "pwd") || strstr(db, "PWD")) {
pwd = NULL;
}
- strncpy( lpszConnStr, db, CONNSTRSIZE);
+ strlcpy( lpszConnStr, db, CONNSTRSIZE);
}
else {
strcpy(lpszConnStr, "DSN=");
- strcat(lpszConnStr, db);
+ strlcat(lpszConnStr, db, CONNSTRSIZE);
}
if (uid) {
if (uid[0]) {
- strcat(lpszConnStr, ";UID=");
- strcat(lpszConnStr, uid);
- strcat(lpszConnStr, ";");
+ strlcat(lpszConnStr, ";UID=", CONNSTRSIZE);
+ strlcat(lpszConnStr, uid, CONNSTRSIZE);
+ strlcat(lpszConnStr, ";", CONNSTRSIZE);
}
if (pwd) {
if (pwd[0]) {
- strcat(lpszConnStr, "PWD=");
- strcat(lpszConnStr, pwd);
- strcat(lpszConnStr, ";");
+ strlcat(lpszConnStr, "PWD=", CONNSTRSIZE);
+ strlcat(lpszConnStr, pwd, CONNSTRSIZE);
+ strlcat(lpszConnStr, ";", CONNSTRSIZE);
}
}
}
@@ -2151,8 +2152,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
if (strstr((char*)db, ";")) {
direct = 1;
if (uid && !strstr ((char*)db, "uid") && !strstr((char*)db, "UID")) {
- ldb = (char*) emalloc(strlen(db) + strlen(uid) + strlen(pwd) + 12);
- sprintf(ldb, "%s;UID=%s;PWD=%s", db, uid, pwd);
+ spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid, pwd);
} else {
ldb_len = strlen(db)+1;
ldb = (char*) emalloc(ldb_len);
diff --git a/ext/odbc/php_odbc.h b/ext/odbc/php_odbc.h
index a1beb4a3e..88926c20f 100644
--- a/ext/odbc/php_odbc.h
+++ b/ext/odbc/php_odbc.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc.h,v 1.60.2.1 2006/01/01 12:50:10 sniper Exp $ */
+/* $Id: php_odbc.h,v 1.60.2.1.2.1 2007/01/01 09:36:04 sebastian Exp $ */
#ifndef PHP_ODBC_H
#define PHP_ODBC_H
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index f35a1c417..7c736967b 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
+ | Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_odbc_includes.h,v 1.12.2.1.2.2 2006/06/19 16:13:15 tony2001 Exp $ */
+/* $Id: php_odbc_includes.h,v 1.12.2.1.2.4 2007/03/13 00:04:38 stas Exp $ */
#ifndef PHP_ODBC_INCLUDES_H
#define PHP_ODBC_INCLUDES_H
@@ -236,7 +236,6 @@ typedef struct odbc_result_value {
typedef struct odbc_result {
ODBC_SQL_STMT_T stmt;
- int id;
odbc_result_value *values;
SWORD numcols;
SWORD numparams;