php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73578 ssh2_auth_pubkey_file destroys its parameters if they contain ~/
Submitted: 2016-11-22 01:14 UTC Modified: -
Votes:8
Avg. Score:4.0 ± 0.9
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:6 (85.7%)
From: chupaka at gmail dot com Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-11-22 01:14 UTC] chupaka at gmail dot com
Description:
------------
When calling ssh2_auth_pubkey_file with $pubkeyfile or $privkeyfile starting with ~/, it destroys contents of strings (and php70 sometimes Segfaults).

Looks like it's connected with "Explode '~/paths' stopgap fix because libssh2 does not accept tilde for homedir" block in ssh2.c

Test script:
---------------
<?php

$pub = '~/.ssh/id_rsa.pub';
$priv = '~/.ssh/id_rsa';

echo "$pub\n$priv\n";

$ssh = ssh2_connect("server.com");
ssh2_auth_pubkey_file($ssh, 'root', $pub, $priv);

echo "$pub\n$priv\n";


Expected result:
----------------
[root@test 1]# php56 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
[root@test 1]# php70 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
[root@test 1]#


Actual result:
--------------
[root@test 1]# php56 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
 d_rsa.pub
▒9▒<d_rsa
[root@test 1]# php70 keyauth.php
~/.ssh/id_rsa.pub
~/.ssh/id_rsa
▒▒;▒>▒▒U▒
▒'▒d_rsa
[root@test 1]#


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-22 20:06 UTC] chupaka at gmail dot com
https://bugs.php.net/bug.php?id=63725
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon May 27 12:01:26 2019 UTC