php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65199 pg_copy_from() modifies input array variable
Submitted: 2013-07-03 23:04 UTC Modified: 2014-10-08 09:00 UTC
From: thuejk at gmail dot com Assigned: yohgaki
Status: Closed Package: PostgreSQL related
PHP Version: 5.5.0 OS: Linux (all?)
Private report: No CVE-ID:
 [2013-07-03 23:04 UTC] thuejk at gmail dot com
Description:
------------
The variable holding the array of values I pass to pg_copy_from() is modified by 
pg_copy_from() (ints are changed to strings). Even though there is no pass-by-
reference involved.

This bug also exists in PHP 5.2 at least.

Test script:
---------------
<?php
function test(Array $values) {
  $params = sprintf("host='%s' dbname='%s' user='%s' password='%s'",
                    "localhost",
                    "thue",
                    "thue",
                    "password");
  $connection = pg_pconnect($params, PGSQL_CONNECT_FORCE_NEW);

  pg_query("begin");
  pg_query("CREATE TABLE test(i INTEGER)");
  pg_copy_from($connection, "test", $values, "\t", "NULL");
  pg_query("rollback");
}

$values = Array(1,2,3);
var_dump($values);
test($values);
var_dump($values);
?>


Expected result:
----------------
The two var_dump()s should return identical outputs.

Actual result:
--------------
t@t ~/php/php-5.5.0> ./sapi/cli/php ~/test.php
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(3) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(1) "3"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 07:40 UTC] mike@php.net
-Assigned To: +Assigned To: yohgaki
 [2013-10-02 07:40 UTC] mike@php.net
Yasuo, can you have a look, please? Probably just a separation issue.
 [2013-10-03 20:27 UTC] yohgaki@php.net
Ok, I will
 [2013-11-28 16:34 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2013-11-28 16:34 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2013-11-28 16:34 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2013-11-28 16:34 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2013-11-28 16:34 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2013-11-28 16:35 UTC] mike@php.net
-Status: Closed +Status: Assigned
 [2013-11-28 16:35 UTC] mike@php.net
Wrong bug number in commit
 [2013-11-28 16:49 UTC] ab@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2013-11-28 16:49 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2013-11-28 17:42 UTC] mike@php.net
-Status: Closed +Status: Assigned
 [2013-11-28 17:42 UTC] mike@php.net
.
 [2014-10-07 23:16 UTC] stas@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2014-10-07 23:16 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2014-10-07 23:25 UTC] stas@php.net
-Status: Closed +Status: Re-Opened
 [2014-10-07 23:27 UTC] stas@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=d22cc5c816fdb6017ce9e22b4594d1566939e4ec
Log: Fixed bug #65199 (Wrong Day of Week) and fixed bug #63391 (Incorrect/inconsistent day of week prior to the year 1600)
 [2014-10-07 23:27 UTC] stas@php.net
-Status: Re-Opened +Status: Closed
 [2014-10-08 09:00 UTC] thuejk at gmail dot com
-Status: Closed +Status: Assigned
 [2014-10-08 09:00 UTC] thuejk at gmail dot com
Still not fixed...
 [2015-02-03 06:43 UTC] yohgaki@php.net
Automatic comment on behalf of yohgaki
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f8a8ccaba2b6c025b686fab60c6e4a1601d81e62
Log: Fixed Bug #65199 pg_copy_from() modifies input array variable
 [2015-02-03 06:43 UTC] yohgaki@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Aug 31 13:01:29 2015 UTC