From 3060dfd92e0126e92b1501dba807bfcd44bef53a Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sat, 7 Nov 2015 01:56:50 +1100 Subject: [PATCH] Fix bug 68298 (PHP OCI8 OCI int overflow) (Senthil) --- ext/oci8/oci8_statement.c | 9 ++++++- ext/oci8/tests/bug68298.phpt | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 ext/oci8/tests/bug68298.phpt diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 4d18a916d8..ad30a65377 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1139,15 +1139,22 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, 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); +#if defined(OCI_MAJOR_VERSION) && OCI_MAJOR_VERSION > 10 + bind_data = (ub8 *)&Z_LVAL_P(var); + value_sz = sizeof(ub8); +#else bind_data = (ub4 *)&Z_LVAL_P(var); value_sz = sizeof(ub4); +#endif mode = OCI_DEFAULT; - break; + } + break; case SQLT_LBI: case SQLT_BIN: diff --git a/ext/oci8/tests/bug68298.phpt b/ext/oci8/tests/bug68298.phpt new file mode 100644 index 0000000000..223faa5cad --- /dev/null +++ b/ext/oci8/tests/bug68298.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #68298 (OCI int overflow) +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECTF-- +array(1) { + ["COL1"]=> + array(2) { + [0]=> + string(19) "1152921504606846975" + [1]=> + string(20) "-1152921504606846975" + } +} +===DONE=== -- 2.40.0