xref: /PHP-8.0/ext/oci8/tests/bug74625.phpt (revision a555cc0b)
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(__DIR__.'/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--EXPECT--
51array(5) {
52  [0]=>
53  int(-2)
54  [1]=>
55  int(-4)
56  [2]=>
57  int(-6)
58  [3]=>
59  int(-8)
60  [4]=>
61  int(-10)
62}
63