php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74667 Wrong file content when using multiple sftp connections
Submitted: 2017-05-28 09:56 UTC Modified: 2021-02-21 04:22 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: simon at nekudo dot com Assigned: cmb (profile)
Status: No Feedback Package: ssh2 (PECL)
PHP Version: 7.0.19 OS: Ubuntu 16.04
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: simon at nekudo dot com
New email:
PHP Version: OS:

 

 [2017-05-28 09:56 UTC] simon at nekudo dot com
Description:
------------
I open two ssh (and sftp) connections to two different servers. Than I fetch a file (same path on both servers) from each server. The content of the files on each server is different. (In this case a 40 char hash value) - but when printing out the results the content is always the one from the first sftp connection.


Not sure if this is the same as: https://bugs.php.net/bug.php?id=72988 


Test script:
---------------
<?php
$ssh1 = ssh2_connect('host.server1.com', 22);
ssh2_auth_password($ssh1, 'user1', 'password1');
$sftp1 = ssh2_sftp($ssh1);
print_r(ssh2_sftp_stat($sftp1, '/var/www/some/path/REVISION'));
$stream1 = fopen('ssh2.sftp://' . (int)$sftp1 . '/var/www/some/path/REVISION', 'r');       
$content1 = '';
while (!feof($stream1)) {
    $content1 .= fread($stream1, 8192);
}
fclose($stream1);
var_dump($content1); // correct result

// If this unset is used, result is as expected
//unset($sftp1);


$ssh2 = ssh2_connect('host.server2.com', 22);
ssh2_auth_password($ssh2, 'user2', 'password2');
$sftp2 = ssh2_sftp($ssh2);
print_r(ssh2_sftp_stat($sftp2, '/var/www/some/path/REVISION'));
$stream2 = fopen('ssh2.sftp://' . (int)$sftp2 . '/var/www/some/path/REVISION', 'r');       
$content2 = '';
while (!feof($stream2)) {
    $content2 .= fread($stream2, 8192);
}
fclose($stream2);
var_dump($content2); // WRONG result (shows content from server1)

Expected result:
----------------
Contents of variables $content1 and $content2 should be different.

Actual result:
--------------
Contents of variables $content1 and $conten2 are the same. ($content2 is wrong)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-10 16:09 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-02-10 16:09 UTC] cmb@php.net
Indeed, this is likely a duplicate of bug #72988, which is fixed
as of ssh2 1.1.  Or can you still reproduce this issue?
 [2021-02-21 04:22 UTC] pecl-dev 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC