php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67437 error processing nvarchar(max) types from SQL Server with MS ODBC Linux Driver
Submitted: 2014-06-13 10:44 UTC Modified: 2015-02-15 04:22 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: laurent dot mirguet at aufeminin dot com Assigned:
Status: No Feedback Package: ODBC related
PHP Version: 5.5.13 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-06-13 10:44 UTC] laurent dot mirguet at aufeminin dot com
Description:
------------
When using the Microsoft ODBC driver for SQL Server on Linux (see http://msdn.microsoft.com/en-us/library/hh568451%28v=sql.110%29.aspx)

Calling odbc_result() on an nvarchar(max) type results in a memory exhausted error as PHP is trying to allocate 4Go of RAM (the max size of an nvarchar type).

This seems to happen in the file ext/odbc/php_odbc.c line 2148 :
- the type nvarchar(max) is not recognized in the code, so the switch falls back in the default case
- and the value of result->values[field_ind].vallen is 4Go

I don't know whether the problem comes from the PHP code, the unixODBC code, or the Microsoft code...

Test script:
---------------
Any odbc_result() call on a non-empty nvarchar(max) type should do the trick and generate a memory exhauted error.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-13 09:19 UTC] stefan dot thuering at gmail dot com
I have a similar problem on Windows 2008 Server.

Running odbc_exec on a nvarchar(max) col in MSSQL crashes PHP 5.5
This was working on PHP 5.4

Error message:
-------------------------
PHP Fatal error:  Out of memory (allocated 786432) (tried to allocate 4294967293 bytes) in ....dbFunction.inc.php on line 27
-------------------------

When the field is nvarchar(4000) everything works.
http://stackoverflow.com/questions/17703180/php-odbc-error-tried-to-allocate-4294967293-bytes
 [2015-02-06 18:08 UTC] ab@php.net
@laurent, please check the current 5.5+ tree.

Thanks.
 [2015-02-06 18:08 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2015-02-15 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-02-19 15:53 UTC] sinasalek at gmail dot com
Using PHP 5.6.5 on Ubuntu Linux 64bit. and still experiencing the same problem.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Mar 24 08:01:26 2019 UTC