Avoid segfault when libssh2_session_methods() called too early
This commit is contained in:
parent
2b414db02e
commit
096ef86627
2
README
2
README
@ -4,6 +4,8 @@ libssh2 - SSH2 library
|
|||||||
Version 0.6
|
Version 0.6
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
Fix segfault when libssh2_session_methods() is called prior to session_startup().
|
||||||
|
|
||||||
Fixed client to server channel windowing. Pervent send queue overruns.
|
Fixed client to server channel windowing. Pervent send queue overruns.
|
||||||
|
|
||||||
Swapped banner send/receive order (send first, then wait for response).
|
Swapped banner send/receive order (send first, then wait for response).
|
||||||
|
@ -488,46 +488,52 @@ LIBSSH2_API int libssh2_session_disconnect_ex(LIBSSH2_SESSION *session, int reas
|
|||||||
*/
|
*/
|
||||||
LIBSSH2_API char *libssh2_session_methods(LIBSSH2_SESSION *session, int method_type)
|
LIBSSH2_API char *libssh2_session_methods(LIBSSH2_SESSION *session, int method_type)
|
||||||
{
|
{
|
||||||
char *methodlist = NULL;
|
/* All methods have char *name as their first element */
|
||||||
|
LIBSSH2_KEX_METHOD *method = NULL;
|
||||||
|
|
||||||
switch(method_type) {
|
switch(method_type) {
|
||||||
case LIBSSH2_METHOD_KEX:
|
case LIBSSH2_METHOD_KEX:
|
||||||
methodlist = session->kex->name;
|
method = session->kex;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_HOSTKEY:
|
case LIBSSH2_METHOD_HOSTKEY:
|
||||||
methodlist = session->hostkey->name;
|
method = (LIBSSH2_KEX_METHOD*)session->hostkey;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_CRYPT_CS:
|
case LIBSSH2_METHOD_CRYPT_CS:
|
||||||
methodlist = session->local.crypt->name;
|
method = (LIBSSH2_KEX_METHOD*)session->local.crypt;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_CRYPT_SC:
|
case LIBSSH2_METHOD_CRYPT_SC:
|
||||||
methodlist = session->remote.crypt->name;
|
method = (LIBSSH2_KEX_METHOD*)session->remote.crypt;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_MAC_CS:
|
case LIBSSH2_METHOD_MAC_CS:
|
||||||
methodlist = session->local.mac->name;
|
method = (LIBSSH2_KEX_METHOD*)session->local.mac;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_MAC_SC:
|
case LIBSSH2_METHOD_MAC_SC:
|
||||||
methodlist = session->remote.mac->name;
|
method = (LIBSSH2_KEX_METHOD*)session->remote.mac;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_COMP_CS:
|
case LIBSSH2_METHOD_COMP_CS:
|
||||||
methodlist = session->local.comp->name;
|
method = (LIBSSH2_KEX_METHOD*)session->local.comp;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_COMP_SC:
|
case LIBSSH2_METHOD_COMP_SC:
|
||||||
methodlist = session->remote.comp->name;
|
method = (LIBSSH2_KEX_METHOD*)session->remote.comp;
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_LANG_CS:
|
case LIBSSH2_METHOD_LANG_CS:
|
||||||
methodlist = "";
|
return "";
|
||||||
break;
|
break;
|
||||||
case LIBSSH2_METHOD_LANG_SC:
|
case LIBSSH2_METHOD_LANG_SC:
|
||||||
methodlist = "";
|
return "";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
libssh2_error(session, LIBSSH2_ERROR_INVAL, "Invalid parameter specified for method_type", 0);
|
libssh2_error(session, LIBSSH2_ERROR_INVAL, "Invalid parameter specified for method_type", 0);
|
||||||
methodlist = NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(methodlist);
|
if (!method) {
|
||||||
|
libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE, "No method negotiated", 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return method->name;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user