php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51609 pg_copy_to: Invalid results when using fourth parameter
Submitted: 2010-04-20 02:41 UTC Modified: 2010-04-20 16:12 UTC
From: cbandy at jbandy dot com Assigned: felipe
Status: Closed Package: PostgreSQL related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID:
 [2010-04-20 02:41 UTC] cbandy at jbandy dot com
Description:
------------
When passing four arguments to pg_copy_to(), the resulting data is corrupted.

My guess is that pg_null_as is being freed improperly. A similar pointer is freed conditionally within pg_copy_from().

Could be related to segfault in bug 35168.

Test script:
---------------
// setup
pg_query($db, 'CREATE TEMP TABLE temp_test_table (a INT)');
pg_query($db, 'INSERT INTO temp_test_table VALUES (1)');

// success
var_dump(pg_copy_to($db, 'temp_test_table'));

// success
var_dump(pg_copy_to($db, 'temp_test_table', "\t"));

// failure
var_dump(pg_copy_to($db, 'temp_test_table', "\t", "\\\\N"));



Expected result:
----------------
Three identical arrays:

array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}

Actual result:
--------------
The third array is corrupted:

array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "1
"
}
array(1) {
  [0]=>
  string(2) "@�"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-20 16:11 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=298218
Log: - Fixed bug #51609 (pg_copy_to: Invalid results when using fourth parameter)
 [2010-04-20 16:12 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-04-20 16:12 UTC] felipe@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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 05:03:19 2014 UTC