Bug #74247 [NEW]: Blob
| From: | support at dsolutions dot lv | Date: | Tue, 14 Mar 2017 21:57:28 +0000 |
| Subject: | Bug #74247 [NEW]: Blob | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207835@lists.php.net to get a copy of this message | ||
From: support at dsolutions dot lv
Operating system: Linux
PHP version: 7.1.3RC1
Package: MySQLi related
Bug Type: Bug
Bug description:Blob
Description:
------------
Since PHP version 7.1.15 when reading a longblob field from MySQL,
mysqlnd driver inserts a 0x00 byte at position 16777204 ( or 2^24-12).
Therefore all data following said zero is shifted 1 byte to the right.
However the total length of the data is unchanged, as the last byte of
the blob is not returned.
Test script is for mysqli, however I was able to reproduce the same
behaviour with pdo.
I have some suspicion that the problem resides within the file
"ext/mysqlnd/mysqlnd_wireprotocol.c" as it was modified for version
7.0.15.
Test script:
---------------
echo "\nPHP version:".phpversion();
$mysqli = new mysqli('localhost', 'root', '', 'test');
$mysqli->query("DROP TABLE IF EXISTS
blob_tb;");
$mysqli->query("CREATE TABLE blob_tb (bdata longblob);");
$sql = "INSERT INTO blob_tb (bdata) VALUES(?)";
$insertStm = $mysqli->prepare($sql);
$blob = NULL;
$insertStm->bind_param('b', $blob);
$crypto_strong=false;
$blob = (binary) openssl_random_pseudo_bytes
(20*1024*1024,$crypto_strong);
$insertStm->send_long_data(0, $blob);
$insertStm->execute();
$insertStm->close();
echo "\nInserted data md5: ".md5($blob).", len ".strlen($blob);
$selectStm = $mysqli->prepare("SELECT bdata FROM blob_tb LIMIT 1");
$selectStm->execute();
$selectStm->bind_result($savedBlob);
$selectStm->fetch();
$selectStm->close();
echo "\nAre the blobs equal?: " . ((int) ($blob == $savedBlob));
echo "\nSelected data: md5: ".md5($savedBlob);
echo "\nSQL md5(): ".$mysqli->query("select md5(bdata) as database_md5
from blob_tb;")->fetch_assoc()['database_md5'];
$mysqli->close();
Expected result:
----------------
PHP version:7.0.14
Inserted data md5: 7792a7fd3351033132f991e7a8e939f3, len 20971520
Are the blobs equal?: 1
Selected data: md5: 7792a7fd3351033132f991e7a8e939f3
SQL md5(): 7792a7fd3351033132f991e7a8e939f3
PHP version:7.0.13-1+deb.sury.org~trusty+1
Inserted data md5: b6130b103663d6facbcba10301dd23e1, len 20971520
Are the blobs equal?: 1
Selected data: md5: b6130b103663d6facbcba10301dd23e1
SQL md5(): b6130b103663d6facbcba10301dd23e1
Actual result:
--------------
On Centos 7:
PHP version:7.0.16
Inserted data md5: 7354bdcb5ee180e069fb686bd289242c, len 20971520
Are the blobs equal?: 0
Selected data: md5: 887f9bbf56e7ad378e8672277d07c267
SQL md5(): 7354bdcb5ee180e069fb686bd289242c
PHP version:7.0.15
Inserted data md5: e13724a895dc46e073c4c7ddb005d09d, len 20971520
Are the blobs equal?: 0
Selected data: md5: aa68f482f6a75ae77027728a09485da0
SQL md5(): e13724a895dc46e073c4c7ddb005d09d
On Ubuntu:
PHP version:7.0.16-4+deb.sury.org~trusty+1
Inserted data md5: 5ab7bb3d517fbfbbd21ec02c48da2d88, len 20971520
Are the blobs equal?: 0
Selected data: md5: 9eb90f968797d617b7385fd166f34067
SQL md5(): 5ab7bb3d517fbfbbd21ec02c48da2d88
--
Edit bug report at https://bugs.php.net/bug.php?id=74247&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74247&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74247&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74247&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74247&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74247&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74247&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74247&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74247&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74247&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74247&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74247&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74247&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74247&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74247&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74247&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74247&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74247&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74247&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74247&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74247&r=mysqlcfg