summaryrefslogtreecommitdiff
path: root/ext/pdo_firebird
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_firebird')
-rw-r--r--ext/pdo_firebird/firebird_driver.c14
-rw-r--r--ext/pdo_firebird/firebird_statement.c41
-rw-r--r--ext/pdo_firebird/pdo_firebird.c4
-rw-r--r--ext/pdo_firebird/php_pdo_firebird.h4
-rw-r--r--ext/pdo_firebird/php_pdo_firebird_int.h4
5 files changed, 37 insertions, 30 deletions
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index 82faa2b39..af9861f96 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.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: firebird_driver.c,v 1.17.2.2 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: firebird_driver.c,v 1.17.2.2.2.4 2007/02/27 03:28:16 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -38,8 +38,10 @@ static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const char*, long, XSQLDA*, i
/* map driver specific error message to PDO error */
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
{
+#if 0
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
: (pdo_firebird_db_handle *)dbh->driver_data;
+#endif
pdo_error_type *const error_code = stmt ? &stmt->error_code : &dbh->error_code;
#if 0
@@ -600,6 +602,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
{ "role", NULL, 0 }
};
int i, ret = 0;
+ short buf_len = 256, dpb_len;
+
pdo_firebird_db_handle *H = dbh->driver_data = pecalloc(1,sizeof(*H),dbh->is_persistent);
php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 3);
@@ -614,9 +618,11 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
/* loop through all the provided arguments and set dpb fields accordingly */
for (i = 0; i < sizeof(dpb_flags); ++i) {
- if (dpb_values[i]) {
- dpb += sprintf(dpb, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
+ if (dpb_values[i] && buf_len > 0) {
+ dpb_len = slprintf(dpb, buf_len, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
dpb_values[i]);
+ dpb += dpb_len;
+ buf_len -= dpb_len;
}
}
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 96947e771..0a72bc151 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.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: firebird_statement.c,v 1.18.2.1 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: firebird_statement.c,v 1.18.2.1.2.5 2007/02/27 03:04:40 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -211,6 +211,8 @@ static void set_param_type(enum pdo_param_type *param_type, XSQLVAR const *var)
#define FETCH_BUF(buf,type,len,lenvar) ((buf) = (buf) ? (buf) : \
emalloc((len) ? (len * sizeof(type)) : ((*(unsigned long*)lenvar) = sizeof(type))))
+#define CHAR_BUF_LEN 24
+
/* fetch a blob into a fetch buffer */
static int firebird_fetch_blob(pdo_stmt_t *stmt, int colno, char **ptr, /* {{{ */
unsigned long *len, ISC_QUAD *blob_id TSRMLS_DC)
@@ -322,16 +324,16 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
n = *(ISC_INT64*)var->sqldata;
}
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
if (n >= 0) {
- *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d",
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d",
n / f, -var->sqlscale, n % f);
} else if (n < -f) {
- *len = sprintf(*ptr, "%" LL_MASK "d.%0*" LL_MASK "d",
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d.%0*" LL_MASK "d",
n / f, -var->sqlscale, -n % f);
} else {
- *len = sprintf(*ptr, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "-0.%0*" LL_MASK "d", -var->sqlscale, -n % f);
}
} else {
switch (var->sqltype & ~1) {
@@ -353,24 +355,24 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
break;
/* --- cut here --- */
case SQL_SHORT:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
- *len = sprintf(*ptr, "%d", *(short*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%d", *(short*)var->sqldata);
break;
case SQL_LONG:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
- *len = sprintf(*ptr, "%ld", *(ISC_LONG*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%ld", *(ISC_LONG*)var->sqldata);
break;
case SQL_INT64:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
- *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
break;
case SQL_FLOAT:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
- *len = sprintf(*ptr, "%f", *(float*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%F", *(float*)var->sqldata);
break;
case SQL_DOUBLE:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 24, NULL);
- *len = sprintf(*ptr, "%f" , *(double*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata);
break;
/* --- cut here --- */
#if abies_0
@@ -391,8 +393,8 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
#if SIZEOF_LONG == 8
*ptr = var->sqldata;
#else
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, 20, NULL);
- *len = sprintf(*ptr, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
+ *len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
#endif
break;
case SQL_FLOAT:
@@ -653,8 +655,7 @@ static int firebird_stmt_set_attribute(pdo_stmt_t *stmt, long attr, zval *val TS
RECORD_ERROR(stmt);
return 0;
}
- strncpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
- S->name[sizeof(S->name)] = 0;
+ strlcpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
break;
}
return 1;
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index dfb985a17..f778cc71a 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.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: pdo_firebird.c,v 1.4.2.3 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: pdo_firebird.c,v 1.4.2.3.2.1 2007/01/01 09:36:04 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/pdo_firebird/php_pdo_firebird.h b/ext/pdo_firebird/php_pdo_firebird.h
index 8545b4be1..1ce59778d 100644
--- a/ext/pdo_firebird/php_pdo_firebird.h
+++ b/ext/pdo_firebird/php_pdo_firebird.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_pdo_firebird.h,v 1.3.2.1 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: php_pdo_firebird.h,v 1.3.2.1.2.1 2007/01/01 09:36:04 sebastian Exp $ */
#ifndef PHP_PDO_FIREBIRD_H
#define PHP_PDO_FIREBIRD_H
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index 01bdce9b2..ed9f9dc01 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.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_pdo_firebird_int.h,v 1.10.2.1 2006/01/01 12:50:11 sniper Exp $ */
+/* $Id: php_pdo_firebird_int.h,v 1.10.2.1.2.1 2007/01/01 09:36:04 sebastian Exp $ */
#ifndef PHP_PDO_FIREBIRD_INT_H
#define PHP_PDO_FIREBIRD_INT_H