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