Bug #76726 [NEW]: Segmentation fault when fetching truncated 4 bytes Unicode character
From: maxiwheat at gmail dot com
Operating system: Linux Slackware 14.1
PHP version: 7.2.8
Package: PDO DBlib
Bug Type: Bug
Bug description:Segmentation fault when fetching truncated 4 bytes Unicode character
Description:
------------
We experienced this issue when a string was inserted in a table column
of type NVARCHAR and that string ended with a 4 bytes unicode character,
but the column was not large enough to contain the whole string, so the
string got truncated, but instead of truncating the whole 4 bytes
character it got truncated in the middle (because SQL Server stores
string as USC-2, 2 bytes per character) and becoming an invalid unicode
character. With SQL Server Management Studio, we can still query that
column without issues, except that the character is replaced by an
invalid character (�)
Test script:
---------------
$conn = new PDO('dblib:host=myhost.local;dbname=MyDB;charset=UTF-8;',
'myuser', 'mypass');
$sql = "DECLARE @test AS NVARCHAR(1) = N'ð'; SELECT @test AS test;";
$stmt = $conn->prepare($sql);
$stmt->execute();
// Skip rowcount result
$stmt->nextRowset();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['test'];
Expected result:
----------------
Outputs truncated string/byte like � or an empty string, does not
segfault.
Actual result:
--------------
Segmentation fault
--
Edit bug report at https://bugs.php.net/bug.php?id=76726&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76726&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76726&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76726&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76726&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76726&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76726&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76726&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76726&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76726&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76726&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76726&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76726&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76726&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76726&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76726&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76726&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76726&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76726&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76726&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76726&r=mysqlcfg
Thread (5 messages)
- maxiwheat at gmail dot com