aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-09-29 12:11:43 +0200
committerAndreas Schneider <asn@cynapses.org>2010-09-29 12:11:43 +0200
commit1b471256d4371f4789da6fa345ead4015623abbe (patch)
tree0c30c95f95c0f71073ee65925aa41a2877d43cfd /src
parent30e22fed6e6bdab222977a2e385defed1f2d0d62 (diff)
downloadlibssh-1b471256d4371f4789da6fa345ead4015623abbe.tar.gz
libssh-1b471256d4371f4789da6fa345ead4015623abbe.tar.xz
libssh-1b471256d4371f4789da6fa345ead4015623abbe.zip
misc: Differentiate between client and server in ssh_analyze_banner.
Diffstat (limited to 'src')
-rw-r--r--src/client.c2
-rw-r--r--src/misc.c10
-rw-r--r--src/server.c2
3 files changed, 10 insertions, 4 deletions
diff --git a/src/client.c b/src/client.c
index f6be34f..f456e0d 100644
--- a/src/client.c
+++ b/src/client.c
@@ -492,7 +492,7 @@ static void ssh_client_connection_callback(ssh_session session){
"SSH server banner: %s", session->serverbanner);
/* 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;
}
/* Here we decide which version of the protocol to use. */
diff --git a/src/misc.c b/src/misc.c
index bed0041..061eaf3 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -688,6 +688,7 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
* server.
*
* @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 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()
*/
-int ssh_analyze_banner(ssh_session session, int *ssh1, int *ssh2) {
- const char *banner = session->clientbanner;
+int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2) {
+ const char *banner;
const char *openssh;
+ if (server) {
+ banner = session->clientbanner;
+ } else {
+ banner = session->serverbanner;
+ }
if (banner == NULL ||
strlen(banner) <= 4 ||
diff --git a/src/server.c b/src/server.c
index b440f2b..ac5eb05 100644
--- a/src/server.c
+++ b/src/server.c
@@ -435,7 +435,7 @@ static void ssh_server_connection_callback(ssh_session session){
"SSH client banner: %s", session->clientbanner);
/* 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;
}
/* Here we decide which version of the protocol to use. */