|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63725 tilde (~) in public and private keyfile paths causes memory corruption
Submitted: 2012-12-08 02:04 UTC Modified: 2021-02-10 11:25 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: tcolton at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: ssh2 (PECL)
PHP Version: 5.4.9 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
23 + 27 = ?
Subscribe to this entry?

 [2012-12-08 02:04 UTC] tcolton at gmail dot com
When you pass in a public or private keyfile path that has a tilde, there seems be 
some memory corruption that causes a segfault or weird issues the next 
time, in the same process, you attempt to authenticate with keyfiles.

If you pass full paths to the keyfiles, the problem goes away.

Test script:
// Attempt one
$connection = ssh2_connect('localhost', 22);
ssh2_auth_pubkey_file($connection, 'user', '~/.ssh/', '~/.ssh/id_rsa');

// Attempt two
$connection = ssh2_connect('localhost', 22);
ssh2_auth_pubkey_file($connection, 'user', '~/.ssh/', '~/.ssh/id_rsa');

// Attempt three
$connection = ssh2_connect('localhost', 22);
ssh2_auth_pubkey_file($connection, 'user', '~/.ssh/', '~/.ssh/id_rsa');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-26 21:24 UTC] camspiers at gmail dot com
I was able to replicate this issue, but I also found a fix. If you run 
unset($connection); after each connection the segfault goes away.
 [2021-02-10 11:25 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-02-10 11:25 UTC]
Closing as duplicate of bug #73578.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 18 14:01:23 2021 UTC