mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
misc: Differentiate between client and server in ssh_analyze_banner.
This commit is contained in:
@@ -30,7 +30,7 @@ int ssh_file_readaccess_ok(const char *file);
|
|||||||
|
|
||||||
char *ssh_path_expand_tilde(const char *d);
|
char *ssh_path_expand_tilde(const char *d);
|
||||||
char *ssh_path_expand_escape(ssh_session session, const char *s);
|
char *ssh_path_expand_escape(ssh_session session, const char *s);
|
||||||
int ssh_analyze_banner(ssh_session session, int *ssh1, int *ssh2);
|
int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2);
|
||||||
|
|
||||||
/* macro for byte ordering */
|
/* macro for byte ordering */
|
||||||
uint64_t ntohll(uint64_t);
|
uint64_t ntohll(uint64_t);
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ static void ssh_client_connection_callback(ssh_session session){
|
|||||||
"SSH server banner: %s", session->serverbanner);
|
"SSH server banner: %s", session->serverbanner);
|
||||||
|
|
||||||
/* Here we analyze the different protocols the server allows. */
|
/* Here we analyze the different protocols the server allows. */
|
||||||
if (ssh_analyze_banner(session, &ssh1, &ssh2) < 0) {
|
if (ssh_analyze_banner(session, 0, &ssh1, &ssh2) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* Here we decide which version of the protocol to use. */
|
/* Here we decide which version of the protocol to use. */
|
||||||
|
|||||||
10
src/misc.c
10
src/misc.c
@@ -688,6 +688,7 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
|
|||||||
* server.
|
* server.
|
||||||
*
|
*
|
||||||
* @param session The session to analyze the banner from.
|
* @param session The session to analyze the banner from.
|
||||||
|
* @param server 0 means we are a client, 1 a server.
|
||||||
* @param ssh1 The variable which is set if it is a SSHv1 server.
|
* @param ssh1 The variable which is set if it is a SSHv1 server.
|
||||||
* @param ssh2 The variable which is set if it is a SSHv2 server.
|
* @param ssh2 The variable which is set if it is a SSHv2 server.
|
||||||
*
|
*
|
||||||
@@ -695,10 +696,15 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
|
|||||||
*
|
*
|
||||||
* @see ssh_get_banner()
|
* @see ssh_get_banner()
|
||||||
*/
|
*/
|
||||||
int ssh_analyze_banner(ssh_session session, int *ssh1, int *ssh2) {
|
int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2) {
|
||||||
const char *banner = session->clientbanner;
|
const char *banner;
|
||||||
const char *openssh;
|
const char *openssh;
|
||||||
|
|
||||||
|
if (server) {
|
||||||
|
banner = session->clientbanner;
|
||||||
|
} else {
|
||||||
|
banner = session->serverbanner;
|
||||||
|
}
|
||||||
|
|
||||||
if (banner == NULL ||
|
if (banner == NULL ||
|
||||||
strlen(banner) <= 4 ||
|
strlen(banner) <= 4 ||
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ static void ssh_server_connection_callback(ssh_session session){
|
|||||||
"SSH client banner: %s", session->clientbanner);
|
"SSH client banner: %s", session->clientbanner);
|
||||||
|
|
||||||
/* Here we analyze the different protocols the server allows. */
|
/* Here we analyze the different protocols the server allows. */
|
||||||
if (ssh_analyze_banner(session, &ssh1, &ssh2) < 0) {
|
if (ssh_analyze_banner(session, 1, &ssh1, &ssh2) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* Here we decide which version of the protocol to use. */
|
/* Here we decide which version of the protocol to use. */
|
||||||
|
|||||||
Reference in New Issue
Block a user