Bug #68298 [Asn->Csd]: OCI int overflow
Edit report at https://bugs.php.net/bug.php?id=68298&edit=1
ID: 68298
Updated by: sixd@php.net
Reported by: perrier dot p at gmail dot com
Summary: OCI int overflow
-Status: Assigned
+Status: Closed
Type: Bug
Package: OCI8 related
Operating System: Debian 7
PHP Version: 5.6.2
Assigned To: sixd
Block user comment: N
Private report: N
New Comment:
Fixed in PHP 5.6.16 and PECL OCI8 2.0.10
https://github.com/php/php-src/commit/3060dfd92e0126e92b1501dba807bfcd44bef53a
Also merged to PHP-7.0
https://github.com/php/php-src/commit/049325ca9662e1d5e6fb2fdc7006b9a68385d9f9
Previous Comments:
------------------------------------------------------------------------
[2015-10-26 18:28:47] zulrang at gmail dot com
Can confirm I've had the same issue, but it was a much bigger problem.
I'm running on Solaris/SPARC, and on SPARC architecture, it's passing only the UPPER
32-bits, resulting in conversion of numbers like 211 to 949187772415.
------------------------------------------------------------------------
[2015-01-28 19:07:33] m8r-f6bdu21 at mailinator dot com
I had the same issue:
---
$retValue = -1;
oci_bind_by_name($stmt, ':retValue', $retValue, -1, SQLT_INT);
⦠// $retValue is set to 0 by statement
oci_execute($stmt);
---
In 64 bit this gives
- PHP: $retValue = 0xFFFFFFFFFFFFFFFF;
- oci: Only lower 32 bit of $retValue is set to 0
- PHP: $retValue = 0xFFFFFFFF00000000;
Since 11.2, OCI supports 64 bit integers:
http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci03typ.htm#LNOCI039
I changed the OCI code to:
bind_data = (ub8 *)&Z_LVAL_P(var);
value_sz = sizeof(ub8);
and it seems to work so I think the fix is fairly simple.
A check should be done to see if OCI version >= 11.2 and if we are building 64 bit, use ub8
instead of ub4.
------------------------------------------------------------------------
[2014-10-24 10:43:57] perrier dot p at gmail dot com
Description:
------------
If you have a NUMBER colonne which can store 64Bit int when you bind it, it will be converted to
INT32 ( ub4 )
in file oci8_statement.c function php_oci_bind_by_name
case SQLT_INT:
case SQLT_NUM:
if (Z_TYPE_P(var) == IS_RESOURCE || Z_TYPE_P(var) == IS_OBJECT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
return 1;
}
convert_to_long(var);
bind_data = (ub4 *)&Z_LVAL_P(var);
value_sz = sizeof(ub4);
mode = OCI_DEFAULT;
break;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68298&edit=1
Thread (4 messages)