From: Ulf Wendel Date: Thu, 24 Mar 2011 13:40:06 +0000 (+0000) Subject: Limit test with 65k params, should crash mysqlnd X-Git-Tag: php-5.3.7RC1~211 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a270348c24c3c336bd4797a046d6db44fc10b239;p=php Limit test with 65k params, should crash mysqlnd --- diff --git a/ext/mysqli/tests/mysqli_stmt_bind_limits.phpt b/ext/mysqli/tests/mysqli_stmt_bind_limits.phpt new file mode 100644 index 0000000000..74ab052e46 --- /dev/null +++ b/ext/mysqli/tests/mysqli_stmt_bind_limits.phpt @@ -0,0 +1,122 @@ +--TEST-- +Bind limits +--SKIPIF-- + +--FILE-- +query($drop) || !$link->query($create)) { + printf("[%03d + 01] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + printf("... table created\n"); + + if (!$stmt = $link->prepare($insert)) { + printf("[%03d + 02] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + if ($stmt->param_count != $num_params * $rows) { + printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); + return false; + } + printf("... statement with %d parameters prepared\n", $stmt->param_count); + + if ($eval) { + if (!eval($stmt_bind_param)) { + printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + } else { + $param_ref = array($stmt_types); + for ($i = 0; $i < $rows; $i++) + for ($j = 0; $j < $num_params; $j++) + $param_ref[] = &$params[($i * $rows) + $j]; + + if (!call_user_func_array(array($stmt, 'bind_param'), $param_ref)) { + printf("[%03d + 03] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + } + if ($stmt->param_count != $num_params * $rows) { + printf("[%03d + 03] Parameter count should be %d but got %d\n", $offset, $num_params * $rows, $stmt->param_count); + return false; + } + + if (!$stmt->execute()) { + printf("[%03d + 04] [%d] %s\n", $offset, $stmt->errno, $stmt->error); + return false; + } + printf("Statement done\n"); + + $stmt->close(); + + if (!($res = $link->query("SELECT * FROM test"))) { + printf("[%03d + 05] [%d] %s\n", $offset, $link->errno, $link->error); + return false; + } + + $row = $res->fetch_row(); + $res->close(); + + for ($i = 0; $i < $num_params; $i++) { + if ($row[$i + 1] != $i) { + printf("[%03d + 06] [%d] %s\n", $offset, $link->errno, $link->error); + } + } + + return true; + } + + if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + } + + var_dump(bind_many(10, $link, 273, 240, true)); + var_dump(bind_many(20, $link, 273, 240, false)); + mysqli_close($link); + print "done!"; +?> +--CLEAN-- + +--XFAIL-- +Statement limits hit, should crash +--EXPECTF-- +TODO +done! \ No newline at end of file