[php-src] Issue #11317: ssh2_scp_send() truncates files, incomplete file saved on remote server

From: Date: Thu, 25 May 2023 11:34:55 +0000
Subject: [php-src] Issue #11317: ssh2_scp_send() truncates files, incomplete file saved on remote server
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244529@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11317
Author: triatic

### Description

The following code:
```php
<?php
$ssh2 = ssh2_connect('example.com');
ssh2_auth_pubkey_file($ssh2, 'ubuntu', 'pubkey', 'privkey');
$sftp = ssh2_sftp($ssh2);
ssh2_sftp_unlink($sftp, 'myfile');
ssh2_scp_send($ssh2, 'myfile', 'myfile');
$myfile = ssh2_sftp_stat($sftp, 'myfile');
if ($myfile['size'] != filesize('myfile')) echo 'File size mismatch, local:
' . filesize('myfile') . ', remote: ' . $myfile['size'] .
"\n";
```

Resulted in this output:
```
File size mismatch, local: 3938770, remote: 2310144
```

But I expected this output instead:

I should get no output as the file sizes on the local and remote servers should match.
ssh2_scp_send() is not sending the whole file to the remote server.

### PHP Version

PHP 8.1.2

### Operating System

_No response_


Thread (1 message)

  • triatic
« previous php.bugs (#244529) next »