Blame SOURCES/libssh-0.7.1-fix_agent_bigendian.patch

17e9d0
--- a/libssh-0.7.2-fix_agent_bigendian.patch	
17e9d0
+++ a/libssh-0.7.2-fix_agent_bigendian.patch	
17e9d0
@@ -0,0 +1,105 @@ 
17e9d0
+From 0425ac9ad0f8f1cefa12b448d31a400ced3e89b9 Mon Sep 17 00:00:00 2001
17e9d0
+From: Andreas Schneider <asn@cryptomilk.org>
17e9d0
+Date: Wed, 14 Oct 2015 20:45:49 +0200
17e9d0
+Subject: [PATCH] agent: Fix agent auth on big endian machines
17e9d0
+
17e9d0
+BUG: https://red.libssh.org/issues/204
17e9d0
+
17e9d0
+Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
17e9d0
+---
17e9d0
+ ConfigureChecks.cmake |  1 +
17e9d0
+ include/libssh/priv.h | 10 ++++++++++
17e9d0
+ src/agent.c           | 17 +++++++++++++----
17e9d0
+ 3 files changed, 24 insertions(+), 4 deletions(-)
17e9d0
+
17e9d0
+diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
17e9d0
+index c0326c2..3587b07 100644
17e9d0
+--- a/ConfigureChecks.cmake
17e9d0
++++ b/ConfigureChecks.cmake
17e9d0
+@@ -56,6 +56,7 @@ check_include_file(libutil.h HAVE_LIBUTIL_H)
17e9d0
+ check_include_file(sys/time.h HAVE_SYS_TIME_H)
17e9d0
+ check_include_file(sys/param.h HAVE_SYS_PARAM_H)
17e9d0
+ check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
17e9d0
++check_include_file(byteswap.h HAVE_BYTESWAP_H)
17e9d0
+ 
17e9d0
+ if (WIN32)
17e9d0
+   check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
17e9d0
+diff --git a/include/libssh/priv.h b/include/libssh/priv.h
17e9d0
+index 95a22c6..b7a80fe 100644
17e9d0
+--- a/include/libssh/priv.h
17e9d0
++++ b/include/libssh/priv.h
17e9d0
+@@ -43,6 +43,16 @@
17e9d0
+ # endif
17e9d0
+ #endif /* !defined(HAVE_STRTOULL) */
17e9d0
+ 
17e9d0
++#ifdef HAVE_BYTESWAP_H
17e9d0
++#include <byteswap.h>
17e9d0
++#endif
17e9d0
++
17e9d0
++#ifndef bswap_32
17e9d0
++#define bswap_32(x) \
17e9d0
++    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
17e9d0
++     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
17e9d0
++#endif
17e9d0
++
17e9d0
+ #ifdef _WIN32
17e9d0
+ 
17e9d0
+ /* Imitate define of inttypes.h */
17e9d0
+diff --git a/src/agent.c b/src/agent.c
17e9d0
+index 922d753..e520773 100644
17e9d0
+--- a/src/agent.c
17e9d0
++++ b/src/agent.c
17e9d0
+@@ -382,6 +382,9 @@ int ssh_agent_get_ident_count(struct ssh_session_struct *session) {
17e9d0
+     ssh_buffer_free(reply);
17e9d0
+     return -1;
17e9d0
+   }
17e9d0
++#ifdef WORDS_BIGENDIAN
17e9d0
++  type = bswap_32(type);
17e9d0
++#endif
17e9d0
+ 
17e9d0
+   SSH_LOG(SSH_LOG_WARN,
17e9d0
+       "Answer type: %d, expected answer: %d",
17e9d0
+@@ -392,7 +395,7 @@ int ssh_agent_get_ident_count(struct ssh_session_struct *session) {
17e9d0
+       return 0;
17e9d0
+   } else if (type != c2) {
17e9d0
+       ssh_set_error(session, SSH_FATAL,
17e9d0
+-          "Bad authentication reply message type: %d", type);
17e9d0
++          "Bad authentication reply message type: %u", type);
17e9d0
+       ssh_buffer_free(reply);
17e9d0
+       return -1;
17e9d0
+   }
17e9d0
+@@ -507,8 +510,8 @@ ssh_string ssh_agent_sign_data(ssh_session session,
17e9d0
+     ssh_buffer reply;
17e9d0
+     ssh_string key_blob;
17e9d0
+     ssh_string sig_blob;
17e9d0
+-    int type = SSH2_AGENT_FAILURE;
17e9d0
+-    int flags = 0;
17e9d0
++    unsigned int type = 0;
17e9d0
++    unsigned int flags = 0;
17e9d0
+     uint32_t dlen;
17e9d0
+     int rc;
17e9d0
+ 
17e9d0
+@@ -572,13 +575,19 @@ ssh_string ssh_agent_sign_data(ssh_session session,
17e9d0
+         ssh_buffer_free(reply);
17e9d0
+         return NULL;
17e9d0
+     }
17e9d0
++#ifdef WORDS_BIGENDIAN
17e9d0
++    type = bswap_32(type);
17e9d0
++#endif
17e9d0
+ 
17e9d0
+     if (agent_failed(type)) {
17e9d0
+         SSH_LOG(SSH_LOG_WARN, "Agent reports failure in signing the key");
17e9d0
+         ssh_buffer_free(reply);
17e9d0
+         return NULL;
17e9d0
+     } else if (type != SSH2_AGENT_SIGN_RESPONSE) {
17e9d0
+-        ssh_set_error(session, SSH_FATAL, "Bad authentication response: %d", type);
17e9d0
++        ssh_set_error(session,
17e9d0
++                      SSH_FATAL,
17e9d0
++                      "Bad authentication response: %u",
17e9d0
++                      type);
17e9d0
+         ssh_buffer_free(reply);
17e9d0
+         return NULL;
17e9d0
+     }
17e9d0
+-- 
17e9d0
+2.5.0
17e9d0
+
17e9d0