php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62244 Invalid UTF-8 may cause backtrace to be truncated in MySQL driver
Submitted: 2012-06-06 20:32 UTC Modified: 2012-06-18 22:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mathieu at mollie dot nl Assigned: patrickallaert (profile)
Status: Closed Package: APM (PECL)
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mathieu at mollie dot nl
New email:
PHP Version: OS:

 

 [2012-06-06 20:32 UTC] mathieu at mollie dot nl
Description:
------------
When you have code that receives data that may be perceived as broken UTF-8 and 
you have a full UTF-8 config for MySQL then MySQL will truncate the backtrace up 
to the first broken byte. 

Suggested fix:

Since APM can not know what data it is dealing with, it should not make any 
assumptions either. Convert the BACKTRACE field in the MySQL schema to the BINARY 
character set:

ALTER TABLE event MODIFY backtrace CHARACTER SET BINARY;


Test script:
---------------
<?php

function h($str)
{
	return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}


function stuff($bericht)
{
	$y = h($bericht);
}

stuff("lalala \xE9 bork bork");

Expected result:
----------------
This backtrace:

#0 htmlspecialchars("lalala ? bork bork", 3, "UTF-8") called at [test.php:5]
#1 h("lalala ? bork bork") called at [test.php:11]
#2 stuff("lalala ? bork bork") called at [test.php:14]

Actual result:
--------------
This backtrace:

#0 htmlspecialchars("lalala                                                                                                                                                                                                                         




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-18 21:28 UTC] patrickallaert@php.net
-Assigned To: +Assigned To: patrickallaert
 [2012-06-18 21:54 UTC] patrickallaert@php.net
Automatic comment from SVN on behalf of patrickallaert
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=326225
Log: Fixed: Bug #62244: Invalid UTF-8 may cause backtrace to be truncated in MySQL driver
 [2012-06-18 21:57 UTC] patrickallaert@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-06-18 21:57 UTC] patrickallaert@php.net
-Status: Assigned +Status: Closed
 [2012-06-18 22:00 UTC] patrickallaert@php.net
Small note:

ALTER TABLE event MODIFY backtrace CHARACTER SET BINARY

generates a MySQL error, it misses the column type (text).

But since:
ALTER TABLE event MODIFY backtrace text CHARACTER SET BINARY;

Is identical to create a blob, I switched to define it as a blob directly:
ALTER TABLE event MODIFY backtrace BLOB;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC