1 |
From 22b42afaee7fc18019696faaa0bf6146f5fbea65 Mon Sep 17 00:00:00 2001 |
2 |
From: =?utf8?q?Johannes=20Schl=C3=BCter?= <johannes@php.net> |
3 |
Date: Fri, 14 Jan 2011 14:57:57 +0000 |
4 |
Subject: [PATCH] - Fix #53551 (PDOStatement execute segfaults for pdo_mysql |
5 |
driver) |
6 |
|
7 |
--- |
8 |
NEWS | 4 ++ |
9 |
ext/pdo_mysql/mysql_statement.c | 3 +- |
10 |
ext/pdo_mysql/tests/bug53551.phpt | 73 +++++++++++++++++++++++++++++++++++++ |
11 |
3 files changed, 78 insertions(+), 2 deletions(-) |
12 |
create mode 100644 ext/pdo_mysql/tests/bug53551.phpt |
13 |
|
14 |
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c |
15 |
index a431598..79694b3 100755 |
16 |
--- a/ext/pdo_mysql/mysql_statement.c |
17 |
+++ b/ext/pdo_mysql/mysql_statement.c |
18 |
@@ -142,8 +142,7 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt TSRMLS_DC) |
19 |
/* (re)bind the parameters */ |
20 |
if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { |
21 |
if (S->params) { |
22 |
- efree(S->params); |
23 |
- S->params = 0; |
24 |
+ memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND)); |
25 |
} |
26 |
pdo_mysql_error_stmt(stmt); |
27 |
if (mysql_stmt_errno(S->stmt) == 2057) { |
28 |
diff --git a/ext/pdo_mysql/tests/bug53551.phpt b/ext/pdo_mysql/tests/bug53551.phpt |
29 |
new file mode 100644 |
30 |
index 0000000..865dcea |
31 |
--- /dev/null |
32 |
+++ b/ext/pdo_mysql/tests/bug53551.phpt |
33 |
@@ -0,0 +1,73 @@ |
34 |
+--TEST-- |
35 |
+Bug #44327 (PDORow::queryString property & numeric offsets / Crash) |
36 |
+--SKIPIF-- |
37 |
+<?php |
38 |
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc'); |
39 |
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); |
40 |
+MySQLPDOTest::skip(); |
41 |
+$db = MySQLPDOTest::factory(); |
42 |
+?> |
43 |
+--FILE-- |
44 |
+<?php |
45 |
+include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'; |
46 |
+$db = MySQLPDOTest::factory(); |
47 |
+ |
48 |
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); |
49 |
+ |
50 |
+$createSql = "CREATE TABLE `bug53551` ( |
51 |
+ `count` bigint(20) unsigned NOT NULL DEFAULT '0' |
52 |
+)"; |
53 |
+ |
54 |
+$db->exec('drop table if exists bug53551'); |
55 |
+$db->exec($createSql); |
56 |
+$db->exec("insert into bug53551 set `count` = 1 "); |
57 |
+$db->exec("SET sql_mode = 'Traditional'"); |
58 |
+$sql = 'UPDATE bug53551 SET `count` = :count'; |
59 |
+$stmt = $db->prepare($sql); |
60 |
+ |
61 |
+$values = array ( |
62 |
+ 'count' => NULL, |
63 |
+); |
64 |
+ |
65 |
+echo "1\n"; |
66 |
+$stmt->execute($values); |
67 |
+var_dump($stmt->errorInfo()); |
68 |
+ |
69 |
+echo "2\n"; |
70 |
+$stmt->execute($values); |
71 |
+var_dump($stmt->errorInfo()); |
72 |
+ |
73 |
+echo "\ndone\n"; |
74 |
+ |
75 |
+?> |
76 |
+--CLEAN-- |
77 |
+<?php |
78 |
+include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'; |
79 |
+$db = MySQLPDOTest::factory(); |
80 |
+$db->exec('DROP TABLE IF EXISTS bug53551'); |
81 |
+?> |
82 |
+--EXPECTF-- |
83 |
+1 |
84 |
+ |
85 |
+Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d |
86 |
+array(3) { |
87 |
+ [0]=> |
88 |
+ string(5) "23000" |
89 |
+ [1]=> |
90 |
+ int(1048) |
91 |
+ [2]=> |
92 |
+ string(29) "Column 'count' cannot be null" |
93 |
+} |
94 |
+2 |
95 |
+ |
96 |
+Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'count' cannot be null in %s on line %d |
97 |
+array(3) { |
98 |
+ [0]=> |
99 |
+ string(5) "23000" |
100 |
+ [1]=> |
101 |
+ int(1048) |
102 |
+ [2]=> |
103 |
+ string(29) "Column 'count' cannot be null" |
104 |
+} |
105 |
+ |
106 |
+done |
107 |
-- |
108 |
1.7.8 |
109 |
|