php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57022 type correction for strict compiler
Submitted: 2006-05-18 08:16 UTC Modified: 2012-06-23 11:37 UTC
From: gk at gknw dot de Assigned: langemeijer (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: Irrelevant OS: NetWare
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gk at gknw dot de
New email:
PHP Version: OS:

 

 [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;



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 14:01 UTC] pollita@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

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).
 [2006-05-19 14:41 UTC] gk at gknw dot de
> 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;
 [2012-06-13 21:22 UTC] langemeijer@php.net
-Assigned To: +Assigned To: langemeijer
 [2012-06-23 11:37 UTC] langemeijer@php.net
-Status: Assigned +Status: Closed
 [2012-06-23 11:37 UTC] langemeijer@php.net
Current solution seems to work, not touching the code anymore. (it's been 6 
years)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 20:01:27 2024 UTC