|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-18 08:16 UTC] gk at gknw dot de
Description:
------------
Hi,
the compiler I have to use for producing a NetWare php_ssh2 binary is very strict, and breaks with const char* type mismatch...
Reproduce code:
---------------
--- ssh2.c.orig Wed Nov 02 00:40:24 2005
+++ ssh2.c Thu May 18 12:44:32 2006
@@ -480,16 +480,16 @@
#if LIBSSH2_APINO < 200412301450
libssh2_session_methods(session, &kex, &hostkey, &crypt_cs, &crypt_sc, &mac_cs, &mac_sc, &comp_cs, &comp_sc, &lang_cs, &lang_sc);
#else
- kex = libssh2_session_methods(session, LIBSSH2_METHOD_KEX);
- hostkey = libssh2_session_methods(session, LIBSSH2_METHOD_HOSTKEY);
- crypt_cs = libssh2_session_methods(session, LIBSSH2_METHOD_CRYPT_CS);
- crypt_sc = libssh2_session_methods(session, LIBSSH2_METHOD_CRYPT_SC);
- mac_cs = libssh2_session_methods(session, LIBSSH2_METHOD_MAC_CS);
- mac_sc = libssh2_session_methods(session, LIBSSH2_METHOD_MAC_SC);
- comp_cs = libssh2_session_methods(session, LIBSSH2_METHOD_COMP_CS);
- comp_sc = libssh2_session_methods(session, LIBSSH2_METHOD_COMP_SC);
- lang_cs = libssh2_session_methods(session, LIBSSH2_METHOD_LANG_CS);
- lang_sc = libssh2_session_methods(session, LIBSSH2_METHOD_LANG_SC);
+ kex = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_KEX);
+ hostkey = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_HOSTKEY);
+ crypt_cs = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_CRYPT_CS);
+ crypt_sc = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_CRYPT_SC);
+ mac_cs = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_MAC_CS);
+ mac_sc = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_MAC_SC);
+ comp_cs = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_COMP_CS);
+ comp_sc = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_COMP_SC);
+ lang_cs = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_LANG_CS);
+ lang_sc = (char*)libssh2_session_methods(session, LIBSSH2_METHOD_LANG_SC);
#endif
array_init(return_value);
@@ -533,7 +533,7 @@
ZEND_FETCH_RESOURCE(session, LIBSSH2_SESSION*, &zsession, -1, PHP_SSH2_SESSION_RES_NAME, le_ssh2_session);
- fingerprint = libssh2_hostkey_hash(session, (flags & PHP_SSH2_FINGERPRINT_SHA1) ? LIBSSH2_HOSTKEY_HASH_SHA1 : LIBSSH2_HOSTKEY_HASH_MD5);
+ fingerprint = (char*)libssh2_hostkey_hash(session, (flags & PHP_SSH2_FINGERPRINT_SHA1) ? LIBSSH2_HOSTKEY_HASH_SHA1 : LIBSSH2_HOSTKEY_HASH_MD5);
if (!fingerprint) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to retreive fingerprint from specified session");
RETURN_FALSE;
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
> Rather than do typecasts on the return value I just changed the local variables to const char* (which they should have been to begin with). Ok, I first wanted to propose that too - however that does only move the casts now to the PHP return values.... so here's a new diff: ============================================================ --- ssh2.c.pol Fri May 19 20:32:58 2006 +++ ssh2.c Fri May 19 20:38:40 2006 @@ -498,23 +498,23 @@ #endif array_init(return_value); - add_assoc_string(return_value, "kex", kex, 1); - add_assoc_string(return_value, "hostkey", hostkey, 1); + add_assoc_string(return_value, "kex", (char*)kex, 1); + add_assoc_string(return_value, "hostkey", (char*)hostkey, 1); ALLOC_INIT_ZVAL(endpoint); array_init(endpoint); - add_assoc_string(endpoint, "crypt", crypt_cs, 1); - add_assoc_string(endpoint, "mac", mac_cs, 1); - add_assoc_string(endpoint, "comp", comp_cs, 1); - add_assoc_string(endpoint, "lang", lang_cs, 1); + add_assoc_string(endpoint, "crypt", (char*)crypt_cs, 1); + add_assoc_string(endpoint, "mac", (char*)mac_cs, 1); + add_assoc_string(endpoint, "comp", (char*)comp_cs, 1); + add_assoc_string(endpoint, "lang", (char*)lang_cs, 1); add_assoc_zval(return_value, "client_to_server", endpoint); ALLOC_INIT_ZVAL(endpoint); array_init(endpoint); - add_assoc_string(endpoint, "crypt", crypt_sc, 1); - add_assoc_string(endpoint, "mac", mac_sc, 1); - add_assoc_string(endpoint, "comp", comp_sc, 1); - add_assoc_string(endpoint, "lang", lang_sc, 1); + add_assoc_string(endpoint, "crypt", (char*)crypt_sc, 1); + add_assoc_string(endpoint, "mac", (char*)mac_sc, 1); + add_assoc_string(endpoint, "comp", (char*)comp_sc, 1); + add_assoc_string(endpoint, "lang", (char*)lang_sc, 1); add_assoc_zval(return_value, "server_to_client", endpoint); } /* }}} */ @@ -553,7 +553,7 @@ RETURN_NULL(); fingerprint_good: if (flags & PHP_SSH2_FINGERPRINT_RAW) { - RETURN_STRINGL(fingerprint, fingerprint_len, 1); + RETURN_STRINGL((char*)fingerprint, fingerprint_len, 1); } else { char *hexchars;