[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c /ext/interbase/tests bug45373.phpt

2008-10-06 Thread Felipe Pena
felipe  Mon Oct  6 14:37:13 2008 UTC

  Added files: (Branch: PHP_5_2)
/php-src/ext/interbase/testsbug45373.phpt 

  Modified files:  
/php-src/ext/interbase  ibase_query.c 
  Log:
  - MFH: Fixed bug #45373 (php crash on query with errors in params)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.11r2=1.23.2.1.2.12diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.11 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.12
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.11   Mon Dec 31 07:20:07 2007
+++ php-src/ext/interbase/ibase_query.c Mon Oct  6 14:37:13 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.11 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.12 2008/10/06 14:37:13 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1819,16 +1819,17 @@
if (bind_n != expected_n) {
php_error_docref(NULL TSRMLS_CC, (bind_n  expected_n) 
? E_WARNING : E_NOTICE,
Statement expects %d arguments, %d given, 
expected_n, bind_n);
+
if (bind_n  expected_n) {
break;
}
-
-   } else if (bind_n  0) { /* have variables to bind */
-   args = (zval ***) do_alloca(ZEND_NUM_ARGS() * 
sizeof(zval **));
+   }
+   
+   /* have variables to bind */
+   args = (zval ***) do_alloca((expected_n + 1) * sizeof(zval **));

-   if (FAILURE == 
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) {
-   break;
-   }
+   if (FAILURE == zend_get_parameters_array_ex((expected_n + 1), 
args)) {
+   break;
}
 
/* Have we used this cursor before and it's still open (exec 
proc has no cursor) ? */

http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/tests/bug45373.phpt?view=markuprev=1.1
Index: php-src/ext/interbase/tests/bug45373.phpt
+++ php-src/ext/interbase/tests/bug45373.phpt
--TEST--
Bug #45373 (php crash on query with errors in params)
--SKIPIF--
?php include(skipif.inc); ?
--FILE--
?php

require(interbase.inc);

$db = ibase_connect($test_base);


$sql = select * from test1 where i = ? and c = ?;

$q = ibase_prepare($db, $sql);
$r = ibase_execute($q, 1, 'test table not created with isql');
var_dump(ibase_fetch_assoc($r));
ibase_free_result($r);

$r = ibase_execute($q, 1, 'test table not created with isql', 1);
var_dump(ibase_fetch_assoc($r));
ibase_free_result($r);

$r = ibase_execute($q, 1);
var_dump(ibase_fetch_assoc($r));

?
--EXPECTF--
array(2) {
  [I]=
  int(1)
  [C]=
  string(32) test table not created with isql
}

Notice: ibase_execute(): Statement expects 2 arguments, 3 given in 
%sbug45373.php on line %d
array(2) {
  [I]=
  int(1)
  [C]=
  string(32) test table not created with isql
}

Warning: ibase_execute(): Statement expects 2 arguments, 1 given in 
%sbug45373.php on line %d

Warning: ibase_fetch_assoc(): supplied argument is not a valid 
Firebird/InterBase result resource in %sbug45373.php on line %d
bool(false)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c

2007-03-15 Thread Antony Dovgal
tony2001Thu Mar 15 22:33:04 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/interbase  ibase_query.c 
  Log:
  fix #40805 (Failure executing function ibase_execute())
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.8r2=1.23.2.1.2.9diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.8 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.9
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.8Tue Feb 27 03:04:40 2007
+++ php-src/ext/interbase/ibase_query.c Thu Mar 15 22:33:04 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.8 2007/02/27 03:04:40 iliaa Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.9 2007/03/15 22:33:04 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -668,13 +668,13 @@
var-sqldata = (void*)buf[i].val;
 
switch (var-sqltype  ~1) {
-   struct tm *t, tmbuf;
+   struct tm t;
 
case SQL_TIMESTAMP:
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
if (Z_TYPE_P(b_var) == IS_LONG) {
-   t = php_gmtime_r(Z_LVAL_P(b_var), 
tmbuf);
+   php_gmtime_r(Z_LVAL_P(b_var), t);
} else {
 #ifdef HAVE_STRPTIME
char *format = 
INI_STR(ibase.timestampformat);
@@ -688,7 +688,7 @@
case SQL_TYPE_TIME:
format = 
INI_STR(ibase.timeformat);
}
-   if (!strptime(Z_STRVAL_P(b_var), 
format, t)) {
+   if (!strptime(Z_STRVAL_P(b_var), 
format, t)) {
/* strptime() cannot handle it, 
so let IB have a try */
break;
}
@@ -699,13 +699,13 @@
 
switch (var-sqltype  ~1) {
default: /* == case SQL_TIMESTAMP */
-   isc_encode_timestamp(t, 
buf[i].val.tsval);
+   isc_encode_timestamp(t, 
buf[i].val.tsval);
break;
case SQL_TYPE_DATE:
-   isc_encode_sql_date(t, 
buf[i].val.dtval);
+   isc_encode_sql_date(t, 
buf[i].val.dtval);
break;
case SQL_TYPE_TIME:
-   isc_encode_sql_time(t, 
buf[i].val.tmval);
+   isc_encode_sql_time(t, 
buf[i].val.tmval);
break;
}
continue;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c

2007-02-24 Thread Ilia Alshanetsky
iliaa   Sat Feb 24 18:00:57 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/interbase  ibase_query.c 
  Log:
  
  strncpy() - strlcpy()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.6r2=1.23.2.1.2.7diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.6 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.7
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.6Sat Feb 24 02:17:24 2007
+++ php-src/ext/interbase/ibase_query.c Sat Feb 24 18:00:56 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.6 2007/02/24 02:17:24 helly Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.7 2007/02/24 18:00:56 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -603,9 +603,8 @@
break;
default:
convert_to_string(val);
-   strncpy(buf, Z_STRVAL_P(val), 
array-el_size);
-   buf[array-el_size-1] = '\0';
-   }   
+   strlcpy(buf, Z_STRVAL_P(val), buf_size);
+   }
}
}
return SUCCESS;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c

2007-01-22 Thread Antony Dovgal
tony2001Mon Jan 22 09:08:28 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/interbase  ibase_query.c 
  Log:
  MFH
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.4r2=1.23.2.1.2.5diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.4 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.5
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.4Thu Jan 18 15:29:30 2007
+++ php-src/ext/interbase/ibase_query.c Mon Jan 22 09:08:28 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.4 2007/01/18 15:29:30 tony2001 Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.5 2007/01/22 09:08:28 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1117,7 +1117,7 @@
}   
case 1:
case 0:
-   if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() ? 
1 : 0 TSRMLS_CC, s|z, query, 
+   if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() ? 
1 : 0 TSRMLS_CC, s, query, 
query_len)) {
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, 
NULL, IBG(default_link), LE_LINK,
le_link, le_plink);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c

2007-01-18 Thread Antony Dovgal
tony2001Thu Jan 18 15:29:31 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/interbase  ibase_query.c 
  Log:
  MFH: use snprintf()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.3r2=1.23.2.1.2.4diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.3 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.4
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.3Mon Jan  1 09:36:02 2007
+++ php-src/ext/interbase/ibase_query.c Thu Jan 18 15:29:30 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.3 2007/01/01 09:36:02 sebastian Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.4 2007/01/18 15:29:30 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -1938,7 +1938,7 @@
add_index_stringl(return_value, 2, var-relname, var-relname_length, 
1);
add_assoc_stringl(return_value, relation, var-relname, 
var-relname_length, 1);
 
-   len = sprintf(buf, %d, var-sqllen);
+   len = snprintf(buf, 16, %d, var-sqllen);
add_index_stringl(return_value, 3, buf, len, 1);
add_assoc_stringl(return_value, length, buf, len, 1);
 
@@ -1957,7 +1957,7 @@
precision = 18;
break;
}
-   len = sprintf(buf, NUMERIC(%d,%d), precision, -var-sqlscale);
+   len = snprintf(buf, 16, NUMERIC(%d,%d), precision, 
-var-sqlscale);
add_index_stringl(return_value, 4, s, len, 1);
add_assoc_stringl(return_value, type, s, len, 1);
} else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/interbase ibase_query.c

2006-11-30 Thread Ilia Alshanetsky
iliaa   Thu Nov 30 16:21:24 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/interbase  ibase_query.c 
  Log:
  Thread safety fixes.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1r2=1.23.2.1.2.1diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.1
--- php-src/ext/interbase/ibase_query.c:1.23.2.1Sun Jan  1 12:50:08 2006
+++ php-src/ext/interbase/ibase_query.c Thu Nov 30 16:21:24 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1 2006/01/01 12:50:08 sniper Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.1 2006/11/30 16:21:24 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -669,14 +669,13 @@
var-sqldata = (void*)buf[i].val;
 
switch (var-sqltype  ~1) {
-   struct tm t;
+   struct tm *t, tmbuf;
 
case SQL_TIMESTAMP:
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
if (Z_TYPE_P(b_var) == IS_LONG) {
-   /* insert timestamp directly */
-   t = *gmtime(Z_LVAL_P(b_var));
+   t = php_gmtime_r(Z_LVAL_P(b_var), 
tmbuf);
} else {
 #ifdef HAVE_STRPTIME
char *format = 
INI_STR(ibase.timestampformat);
@@ -690,7 +689,7 @@
case SQL_TYPE_TIME:
format = 
INI_STR(ibase.timeformat);
}
-   if (! strptime(Z_STRVAL_P(b_var), 
format, t)) {
+   if (!strptime(Z_STRVAL_P(b_var), 
format, t)) {
/* strptime() cannot handle it, 
so let IB have a try */
break;
}
@@ -701,13 +700,13 @@
 
switch (var-sqltype  ~1) {
default: /* == case SQL_TIMESTAMP */
-   isc_encode_timestamp(t, 
buf[i].val.tsval);
+   isc_encode_timestamp(t, 
buf[i].val.tsval);
break;
case SQL_TYPE_DATE:
-   isc_encode_sql_date(t, 
buf[i].val.dtval);
+   isc_encode_sql_date(t, 
buf[i].val.dtval);
break;
case SQL_TYPE_TIME:
-   isc_encode_sql_time(t, 
buf[i].val.tmval);
+   isc_encode_sql_time(t, 
buf[i].val.tmval);
break;
}
continue;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php