[PECL-CVS] [pecl-networking-ssh2] master: Fix call to ssh2_auth_pubkey_file() without password
[email protected] (Thomas via Casper Langemeijer)
| Newsgroups | php.pecl.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Thomas
Committer: Casper Langemeijer (langemeijer)
Date: 2025-11-23T12:25:11+01:00
Commit: https://github.com/php/pecl-networking-ssh2/commit/10ca442ab2891f40057ab936146cfadbc5a03722
Raw diff: https://github.com/php/pecl-networking-ssh2/commit/10ca442ab2891f40057ab936146cfadbc5a03722.diff
Fix call to ssh2_auth_pubkey_file() without password
Patch taken from
https://bugs.php.net/patch-display.php?bug=79702&patch=ssh2_fix_nullpointer_deref.patch&revision=1617965812
by thomas at shadowweb dot org
Resolves: https://bugs.php.net/bug.php?id=79702
Changed paths:
M ssh2.c
Diff:
diff --git a/ssh2.c b/ssh2.c
index e6fe36a..e831967 100644
--- a/ssh2.c
+++ b/ssh2.c
@@ -653,7 +653,7 @@ PHP_FUNCTION(ssh2_auth_pubkey_file)
{
LIBSSH2_SESSION *session;
zval *zsession;
- zend_string *username, *pubkey, *privkey, *passphrase;
+ zend_string *username, *pubkey, *privkey, *passphrase = NULL;
#ifndef PHP_WIN32
zend_string *newpath;
struct passwd *pws;
@@ -689,7 +689,7 @@ PHP_FUNCTION(ssh2_auth_pubkey_file)
#endif
/* TODO: Support passphrase callback */
- if (libssh2_userauth_publickey_fromfile_ex(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_VAL(privkey), ZSTR_VAL(passphrase))) {
+ if (libssh2_userauth_publickey_fromfile_ex(session, ZSTR_VAL(username), ZSTR_LEN(username), ZSTR_VAL(pubkey), ZSTR_VAL(privkey), passphrase ? ZSTR_VAL(passphrase) : NULL)) {
char *buf;
int len;
libssh2_session_last_error(session, &buf, &len, 0);