|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68298 OCI int overflow
Submitted: 2014-10-24 10:43 UTC Modified: 2015-11-06 15:39 UTC
Avg. Score:4.8 ± 0.4
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: perrier dot p at gmail dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.6.2 OS: Debian 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: perrier dot p at gmail dot com
New email:
PHP Version: OS:


 [2014-10-24 10:43 UTC] perrier dot p at gmail dot com
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;
		 bind_data = (ub4 *)&Z_LVAL_P(var);
		 value_sz = sizeof(ub4);
		 mode = OCI_DEFAULT;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-28 19:07 UTC] 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
In 64 bit this gives
- oci: Only lower 32 bit of $retValue is set to 0
- PHP: $retValue = 0xFFFFFFFF00000000;

Since 11.2, OCI supports 64 bit integers:

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.
 [2015-09-04 22:42 UTC]
-Assigned To: +Assigned To: sixd
 [2015-10-26 18:28 UTC] 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-11-06 15:39 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 07:01:29 2024 UTC