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