|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68544 Mysqlnd fails with compression active and big random data
Submitted: 2014-12-03 20:03 UTC Modified: 2020-10-15 13:03 UTC
From: Assigned: nikic (profile)
Status: Closed Package: MySQLi related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2014-12-03 20:03 UTC]
If the compressed packet payload is bigger than 0xffffff (because DEFLATE increased the size), then the payload length will overflow on 24 bit boundary and PHP ends up with a warning and fails.

Test script:
ini_set("memory_limit", "1G");
$db = mysqli_init();
$db->real_connect(HOST, USER, PASS, DB, 3306, null, MYSQL_CLIENT_COMPRESS);
$q = $db->prepare("INSERT INTO tmp (text) VALUES (?)");
$n = null;
$q->bind_param('b', $n);
$x = file_get_contents("/dev/urandom", 0, null, -1, 0xffffff - 1);
$q->send_long_data(0, $x);

Expected result:
Successful insert in database...

Actual result:
Warning: Error while sending STMT_SEND_LONG_DATA packet. PID=%d in %s on line %d

(Doesn't matter if QUERY, PREPARE or STMT_SEND_LONG_DATA packet or what ever; issue is always the same.)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-03 20:03 UTC]
-Assigned To: +Assigned To: mysql
 [2014-12-03 20:08 UTC]
-Summary: Mysql fails with compression active and big random data +Summary: Mysqlnd fails with compression active and big random data
 [2017-10-24 08:14 UTC]
-Status: Assigned +Status: Open -Assigned To: mysql +Assigned To:
 [2020-10-15 13:03 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-10-15 13:03 UTC]
This was fixed a while ago by
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 21 08:01:23 2020 UTC