[PECL-CVS] [pecl-networking-ssh2] master: fixes #91 (#92)

[email protected] (Rasmus Lerdorf via GitHub) Sat, 4 Apr 2026 09:54:55 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Committer: GitHub (web-flow)
Pusher: rlerdorf
Date: 2026-04-04T05:54:52-04:00

Commit: https://github.com/php/pecl-networking-ssh2/commit/54fe87b9af5892a640dda8715a1b392cb7dc54b5
Raw diff: https://github.com/php/pecl-networking-ssh2/commit/54fe87b9af5892a640dda8715a1b392cb7dc54b5.diff

fixes #91 (#92)

* fixes #91

* Fix Windows CI

* address reviews

* use pr branch of setup-php-sdk to fix CI

* Remove broken PHP 8.0 CI and add 8.5

Changed paths:
  M  .github/workflows/build.yml
  M  ssh2.c


Diff:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bd9adc1..176a148 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,7 +18,7 @@ jobs:
         strategy:
             fail-fast: false
             matrix:
-                php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
+                php: ["8.1", "8.2", "8.3", "8.4", "8.5"]
                 arch: [x86, x64]
                 ts: [nts, ts]
                 experimental: [false]
@@ -36,7 +36,7 @@ jobs:
                     echo $extension_version >> $env:GITHUB_ENV
                 - name: Setup PHP
                   id: setup-php
-                  uses: php/[email protected]
+                  uses: php/setup-php-sdk@fix/invoke-webrequest-tls
                   with:
                       version: ${{matrix.php}}
                       arch: ${{matrix.arch}}
@@ -73,6 +73,7 @@ jobs:
                     if ('8.2' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs16' }
                     if ('8.3' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs16' }
                     if ('8.4' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs17' }
+                    if ('8.5' -eq '${{matrix.php}}') { $artifact_name = $artifact_name + '-vs17' }
 
                     if ('nts' -eq '${{matrix.ts}}') { $artifact_name = $artifact_name + '-nts' }
                     if ('x64' -eq '${{matrix.arch}}') { $artifact_name = $artifact_name + '-x86_64' }
diff --git a/ssh2.c b/ssh2.c
index bc21083..70093b4 100644
--- a/ssh2.c
+++ b/ssh2.c
@@ -50,29 +50,28 @@ int le_ssh2_pkey_subsys;
    ************* */
 
 /* {{{ php_ssh2_alloc_cb
- * Wrap emalloc()
+ * Use system malloc to avoid allocator mismatch: libssh2 1.11.1
+ * _libssh2_ecdsa_sign() allocates via LIBSSH2_ALLOC but frees via
+ * OPENSSL_clear_free, crashing when emalloc is the registered allocator.
+ * https://github.com/libssh2/libssh2/issues/1828
  */
 static LIBSSH2_ALLOC_FUNC(php_ssh2_alloc_cb)
 {
-	return emalloc(count);
+	return malloc(count);
 }
 /* }}} */
 
-/* {{{ php_ssh2_free_cb
- * Wrap efree()
- */
+/* {{{ php_ssh2_free_cb */
 static LIBSSH2_FREE_FUNC(php_ssh2_free_cb)
 {
-	efree(ptr);
+	free(ptr);
 }
 /* }}} */
 
-/* {{{ php_ssh2_realloc_cb
- * Wrap erealloc()
- */
+/* {{{ php_ssh2_realloc_cb */
 static LIBSSH2_REALLOC_FUNC(php_ssh2_realloc_cb)
 {
-	return erealloc(ptr, count);
+	return realloc(ptr, count);
 }
 /* }}} */
 
@@ -602,8 +601,8 @@ static void kbd_callback(const char *name, int name_len,
 	(void)instruction;
 	(void)instruction_len;
 	if (num_prompts == 1) {
-		responses[0].text = estrdup(password_for_kbd_callback);
-		responses[0].length = strlen(password_for_kbd_callback);
+		responses[0].text = strdup(password_for_kbd_callback);
+		responses[0].length = responses[0].text ? strlen(password_for_kbd_callback) : 0;
 	}
 	(void)prompts;
 	(void)abstract;