xref: /PHP-7.2/ext/oci8/tests/bug74625.phpt (revision bdd67d81)
1--TEST--
2Bug #74625 (Integer overflow in oci_bind_array_by_name)
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die ("skip no oci8 extension");
6?>
7--FILE--
8<?php
9require(dirname(__FILE__).'/connect.inc');
10
11// Initialization
12
13$stmtarray = array(
14        "CREATE TABLE bug74625_tab (NAME NUMBER)",
15        "CREATE OR REPLACE PACKAGE PKG74625 AS
16          TYPE ARRTYPE IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
17          PROCEDURE iobind(c1 IN OUT ARRTYPE);
18         END PKG74625;",
19        "CREATE OR REPLACE PACKAGE BODY PKG74625 AS
20          PROCEDURE iobind(c1 IN OUT ARRTYPE) IS
21          BEGIN
22           FOR i IN 1..5 LOOP
23            c1(i) := c1(i) * 2;
24           END LOOP;
25          END iobind;
26         END PKG74625;"
27);
28
29oci8_test_sql_execute($c, $stmtarray);
30
31$statement = oci_parse($c, "BEGIN pkg74625.iobind(:c1); END;");
32
33$array = Array(-1,-2,-3,-4,-5);
34
35oci_bind_array_by_name($statement, ":c1", $array, 5, -1, SQLT_INT);
36
37oci_execute($statement);
38
39var_dump($array);
40
41// Cleanup
42$stmtarray = array(
43    "DROP TABLE bug74625_tab",
44    "DROP PACKAGE PKG74625"
45);
46
47oci8_test_sql_execute($c, $stmtarray);
48
49?>
50===DONE===
51<?php exit(0); ?>
52--EXPECT--
53array(5) {
54  [0]=>
55  int(-2)
56  [1]=>
57  int(-4)
58  [2]=>
59  int(-6)
60  [3]=>
61  int(-8)
62  [4]=>
63  int(-10)
64}
65===DONE===
66