diff -Nru libssh-0.7.4/ChangeLog libssh-0.7.5/ChangeLog --- libssh-0.7.4/ChangeLog 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/ChangeLog 2017-04-13 14:32:16.000000000 +0000 @@ -1,5 +1,12 @@ ChangeLog ========== + +version 0.7.5 (released 2017-04-13) + * Fixed a memory allocation issue with buffers + * Fixed PKI on Windows + * Fixed some SSHv1 functions + * Fixed config hostname expansion + version 0.7.4 (released 2017-02-03) * Added id_ed25519 to the default identity list * Fixed sftp EOF packet handling diff -Nru libssh-0.7.4/cmake/Modules/FindGCrypt.cmake libssh-0.7.5/cmake/Modules/FindGCrypt.cmake --- libssh-0.7.4/cmake/Modules/FindGCrypt.cmake 2016-05-02 04:20:57.000000000 +0000 +++ libssh-0.7.5/cmake/Modules/FindGCrypt.cmake 2017-04-11 15:41:28.000000000 +0000 @@ -35,6 +35,8 @@ gcrypt.h HINTS ${_GCRYPT_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + include ) find_library(GCRYPT_LIBRARY @@ -44,6 +46,8 @@ libgcrypt-11 HINTS ${_GCRYPT_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib ) set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY}) diff -Nru libssh-0.7.4/CMakeLists.txt libssh-0.7.5/CMakeLists.txt --- libssh-0.7.4/CMakeLists.txt 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/CMakeLists.txt 2017-04-13 14:32:48.000000000 +0000 @@ -8,7 +8,7 @@ set(APPLICATION_VERSION_MAJOR "0") set(APPLICATION_VERSION_MINOR "7") -set(APPLICATION_VERSION_PATCH "4") +set(APPLICATION_VERSION_PATCH "5") set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") @@ -19,7 +19,7 @@ # Increment AGE. Set REVISION to 0 # If the source code was changed, but there were no interface changes: # Increment REVISION. -set(LIBRARY_VERSION "4.4.1") +set(LIBRARY_VERSION "4.4.2") set(LIBRARY_SOVERSION "4") # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked diff -Nru libssh-0.7.4/debian/changelog libssh-0.7.5/debian/changelog --- libssh-0.7.4/debian/changelog 2017-02-06 12:50:51.000000000 +0000 +++ libssh-0.7.5/debian/changelog 2017-04-19 11:15:57.000000000 +0000 @@ -1,3 +1,37 @@ +libssh (0.7.5-0up4) yakkety; urgency=medium + + * Team upload. + * yakkety packaging + + -- David Kedves Wed, 19 Apr 2017 13:15:57 +0200 + +libssh (0.7.5-0up3) xenial; urgency=medium + + * Team upload. + * xenial packaging + + -- David Kedves Wed, 19 Apr 2017 13:15:56 +0200 + +libssh (0.7.5-0up2) trusty; urgency=medium + + * Team upload. + * trusty packaging + + -- David Kedves Wed, 19 Apr 2017 13:15:55 +0200 + +libssh (0.7.5-0up1) precise; urgency=medium + + * Team upload. + * precise packaging + + -- David Kedves Wed, 19 Apr 2017 13:15:54 +0200 + +libssh (0.7.5-0up0) UNRELEASED; urgency=medium + + * New official release (0.7.5) + + -- David Kedves Wed, 19 Apr 2017 13:12:57 +0200 + libssh (0.7.4-0up5) yakkety; urgency=medium * Team upload. diff -Nru libssh-0.7.4/.git/COMMIT_EDITMSG libssh-0.7.5/.git/COMMIT_EDITMSG --- libssh-0.7.4/.git/COMMIT_EDITMSG 2017-02-06 12:44:58.000000000 +0000 +++ libssh-0.7.5/.git/COMMIT_EDITMSG 2017-04-19 11:13:33.000000000 +0000 @@ -1 +1 @@ -Upgrade from upstream 0.7.4 +0.7.5 import Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/index and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/index differ diff -Nru libssh-0.7.4/.git/logs/HEAD libssh-0.7.5/.git/logs/HEAD --- libssh-0.7.4/.git/logs/HEAD 2017-02-06 12:45:01.000000000 +0000 +++ libssh-0.7.5/.git/logs/HEAD 2017-04-19 11:13:33.000000000 +0000 @@ -1 +1,2 @@ 48010ebb729503d77f54383160e048d3b84b1195 05f64723a26ca65af0416468a6126e5e1fdb21d8 David Kedves 1486385098 +0100 commit: Upgrade from upstream 0.7.4 +05f64723a26ca65af0416468a6126e5e1fdb21d8 ae72fa6cf9633833249a7bbacfb8623960a9114e David Kedves 1492600413 +0200 commit: 0.7.5 import diff -Nru libssh-0.7.4/.git/logs/refs/heads/master libssh-0.7.5/.git/logs/refs/heads/master --- libssh-0.7.4/.git/logs/refs/heads/master 2017-02-06 12:45:01.000000000 +0000 +++ libssh-0.7.5/.git/logs/refs/heads/master 2017-04-19 11:13:33.000000000 +0000 @@ -1 +1,2 @@ 48010ebb729503d77f54383160e048d3b84b1195 05f64723a26ca65af0416468a6126e5e1fdb21d8 David Kedves 1486385098 +0100 commit: Upgrade from upstream 0.7.4 +05f64723a26ca65af0416468a6126e5e1fdb21d8 ae72fa6cf9633833249a7bbacfb8623960a9114e David Kedves 1492600413 +0200 commit: 0.7.5 import Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/37/214898880a80f0d27af2812705e025f83093c9 and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/37/214898880a80f0d27af2812705e025f83093c9 differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/47/311f18eb5efb66565dde2ef685955352e7715e and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/47/311f18eb5efb66565dde2ef685955352e7715e differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/49/e10b658a22b511193dbff5d0040dec7a9914a1 and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/49/e10b658a22b511193dbff5d0040dec7a9914a1 differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/56/6701ca66a1121779bee5f147e70d24348b0d63 and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/56/6701ca66a1121779bee5f147e70d24348b0d63 differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/6a/111a1a19af916e100368301e79af2496581f5a and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/6a/111a1a19af916e100368301e79af2496581f5a differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/6b/94df5b95affa9a404570c2794b23f27c04b9a8 and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/6b/94df5b95affa9a404570c2794b23f27c04b9a8 differ Binary files /tmp/tmpgkNJVB/qA_FDItVH6/libssh-0.7.4/.git/objects/71/8750aef15c6dd5897935123f437cea8e5c351d and /tmp/tmpgkNJVB/ySz63y4O8u/libssh-0.7.5/.git/objects/71/8750aef15c6dd5897935123f437cea8e5c351d differ diff -Nru libssh-0.7.4/.git/objects/71/c764096c03609e479c493b6b058de497891c87 libssh-0.7.5/.git/objects/71/c764096c03609e479c493b6b058de497891c87 --- libssh-0.7.4/.git/objects/71/c764096c03609e479c493b6b058de497891c87 1970-01-01 00:00:00.000000000 +0000 +++ libssh-0.7.5/.git/objects/71/c764096c03609e479c493b6b058de497891c87 2017-04-19 11:13:33.000000000 +0000 @@ -0,0 +1 @@ +x+)JMU07e040031QpMN,.)+(aX 4㥾RZ[iw L @!'38=`ǘܫB5bLe \ No newline at end of file diff -Nru libssh-0.7.4/.git/objects/7b/44408a5e9385e037dc4457db25ad5ddae8ae0d libssh-0.7.5/.git/objects/7b/44408a5e9385e037dc4457db25ad5ddae8ae0d --- libssh-0.7.4/.git/objects/7b/44408a5e9385e037dc4457db25ad5ddae8ae0d 1970-01-01 00:00:00.000000000 +0000 +++ libssh-0.7.5/.git/objects/7b/44408a5e9385e037dc4457db25ad5ddae8ae0d 2017-04-19 11:13:33.000000000 +0000 @@ -0,0 +1,3 @@ +xڽVmoFg_UUOVu%bsk;Դb/z(f~_l<켭gI6۟~t {yà+kK#q2KÎ' uB1*8!F%[ZqI{QU.Y<+QP˰_Jn_[ 1ĺ;#٢( r{G(>W,YbSTk*yuo*ə˃FtLO}h5vE FM6'77FN^٪ +**|.To~@wcI<|CX[&r,;=wh|s?;|xU)ӅQ{<6Wq+NۼA|OY.}A,ߊVՂB.ؐq|*bK,qD+u4r.ea^KːQ:pos + len < len || buffer->pos + len > buffer->used) { - return 0; + rc = ssh_buffer_validate_length(buffer, len); + if (rc != SSH_OK) { + return 0; } memcpy(data,buffer->data+buffer->pos,len); buffer->pos+=len; @@ -618,6 +621,24 @@ } /** + * @brief Valdiates that the given length can be obtained from the buffer. + * + * @param[in] buffer The buffer to read from. + * + * @param[in] len The length to be checked. + * + * @return SSH_OK if the length is valid, SSH_ERROR otherwise. + */ +int ssh_buffer_validate_length(struct ssh_buffer_struct *buffer, size_t len) +{ + if (buffer->pos + len < len || buffer->pos + len > buffer->used) { + return SSH_ERROR; + } + + return SSH_OK; +} + +/** * @internal * * @brief Get a SSH String out of the buffer and adjusts the read pointer. @@ -630,13 +651,15 @@ uint32_t stringlen; uint32_t hostlen; struct ssh_string_struct *str = NULL; + int rc; if (buffer_get_u32(buffer, &stringlen) == 0) { return NULL; } hostlen = ntohl(stringlen); /* verify if there is enough space in buffer to get it */ - if (buffer->pos + hostlen < hostlen || buffer->pos + hostlen > buffer->used) { + rc = ssh_buffer_validate_length(buffer, hostlen); + if (rc != SSH_OK) { return NULL; /* it is indeed */ } str = ssh_string_new(hostlen); @@ -867,11 +890,13 @@ char **cstring; void **data; } o; - size_t len, rlen; + size_t len, rlen, max_len; uint32_t u32len; va_list ap_copy; int count; + max_len = ssh_buffer_get_len(buffer); + /* copy the argument list in case a rollback is needed */ va_copy(ap_copy, ap); @@ -921,10 +946,16 @@ break; } len = ntohl(u32len); - if (len > UINT_MAX - 1){ + if (len > max_len - 1) { rc = SSH_ERROR; break; } + + rc = ssh_buffer_validate_length(buffer, len); + if (rc != SSH_OK) { + break; + } + *o.cstring = malloc(len + 1); if (*o.cstring == NULL){ rc = SSH_ERROR; @@ -942,6 +973,15 @@ break; case 'P': len = va_arg(ap, size_t); + if (len > max_len - 1) { + rc = SSH_ERROR; + break; + } + + rc = ssh_buffer_validate_length(buffer, len); + if (rc != SSH_OK) { + break; + } o.data = va_arg(ap, void **); count++; diff -Nru libssh-0.7.4/src/config.c libssh-0.7.5/src/config.c --- libssh-0.7.4/src/config.c 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/src/config.c 2017-04-13 14:26:19.000000000 +0000 @@ -50,6 +50,8 @@ SOC_GSSAPISERVERIDENTITY, SOC_GSSAPICLIENTIDENTITY, SOC_GSSAPIDELEGATECREDENTIALS, + + SOC_END /* Keep this one last in the list */ }; struct ssh_config_keyword_table_s { @@ -185,7 +187,7 @@ } static int ssh_config_parse_line(ssh_session session, const char *line, - unsigned int count, int *parsing) { + unsigned int count, int *parsing, int seen[]) { enum ssh_config_opcode_e opcode; const char *p; char *s, *x; @@ -216,6 +218,12 @@ } opcode = ssh_config_get_opcode(keyword); + if (*parsing == 1 && opcode != SOC_HOST) { + if (seen[opcode] == 0) { + return 0; + } + seen[opcode] = 1; + } switch (opcode) { case SOC_HOST: { @@ -227,18 +235,12 @@ p != NULL && p[0] != '\0'; p = ssh_config_get_str_tok(&s, NULL)) { if (ok >= 0) { - char *z = ssh_path_expand_escape(session, p); - - if (z == NULL) { - z = strdup(p); - } - ok = match_hostname(lowerhost, z, strlen(z)); + ok = match_hostname(lowerhost, p, strlen(p)); if (ok < 0) { *parsing = 0; } else if (ok > 0) { *parsing = 1; } - free(z); } } SAFE_FREE(lowerhost); @@ -247,7 +249,12 @@ case SOC_HOSTNAME: p = ssh_config_get_str_tok(&s, NULL); if (p && *parsing) { - ssh_options_set(session, SSH_OPTIONS_HOST, p); + char *z = ssh_path_expand_escape(session, p); + if (z == NULL) { + z = strdup(p); + } + ssh_options_set(session, SSH_OPTIONS_HOST, z); + free(z); } break; case SOC_PORT: @@ -384,6 +391,7 @@ unsigned int count = 0; FILE *f; int parsing; + int seen[SOC_END - SOC_UNSUPPORTED] = {0}; if ((f = fopen(filename, "r")) == NULL) { return 0; @@ -394,7 +402,7 @@ parsing = 1; while (fgets(line, sizeof(line), f)) { count++; - if (ssh_config_parse_line(session, line, count, &parsing) < 0) { + if (ssh_config_parse_line(session, line, count, &parsing, seen) < 0) { fclose(f); return -1; } diff -Nru libssh-0.7.4/src/messages.c libssh-0.7.5/src/messages.c --- libssh-0.7.4/src/messages.c 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/src/messages.c 2017-04-13 14:26:19.000000000 +0000 @@ -1355,7 +1355,8 @@ msg->global_request.bind_port); session->common.callbacks->global_request_function(session, msg, session->common.callbacks->userdata); } else { - ssh_message_reply_default(msg); + ssh_message_queue(session, msg); + return rc; } } else if (strcmp(request, "cancel-tcpip-forward") == 0) { r = ssh_buffer_unpack(packet, "sd", @@ -1374,7 +1375,8 @@ if(ssh_callbacks_exists(session->common.callbacks, global_request_function)) { session->common.callbacks->global_request_function(session, msg, session->common.callbacks->userdata); } else { - ssh_message_reply_default(msg); + ssh_message_queue(session, msg); + return rc; } } else { SSH_LOG(SSH_LOG_PROTOCOL, "UNKNOWN SSH_MSG_GLOBAL_REQUEST %s %d", request, want_reply); diff -Nru libssh-0.7.4/src/pki.c libssh-0.7.5/src/pki.c --- libssh-0.7.4/src/pki.c 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/src/pki.c 2017-04-13 14:26:19.000000000 +0000 @@ -955,7 +955,7 @@ return SSH_ERROR; } - file = fopen(filename, "r"); + file = fopen(filename, "rb"); if (file == NULL) { ssh_pki_log("Error opening %s: %s", filename, strerror(errno)); @@ -1233,7 +1233,7 @@ return SSH_ERROR; } - fp = fopen(filename, "w+"); + fp = fopen(filename, "wb+"); if (fp == NULL) { return SSH_ERROR; } diff -Nru libssh-0.7.4/src/session.c libssh-0.7.5/src/session.c --- libssh-0.7.4/src/session.c 2017-02-03 08:51:50.000000000 +0000 +++ libssh-0.7.5/src/session.c 2017-04-13 14:26:19.000000000 +0000 @@ -31,6 +31,9 @@ #include "libssh/crypto.h" #include "libssh/server.h" #include "libssh/socket.h" +#ifdef WITH_SSH1 +#include "libssh/ssh1.h" +#endif /* WITH_SSH1 */ #include "libssh/ssh2.h" #include "libssh/agent.h" #include "libssh/packet.h" @@ -830,13 +833,17 @@ * @return SSH_OK on success, SSH_ERROR otherwise. */ int ssh_send_ignore (ssh_session session, const char *data) { +#ifdef WITH_SSH1 + const int type = session->version == 1 ? SSH_MSG_IGNORE : SSH2_MSG_IGNORE; +#else /* WITH_SSH1 */ + const int type = SSH2_MSG_IGNORE; +#endif /* WITH_SSH1 */ int rc; if (ssh_socket_is_open(session->socket)) { - rc = ssh_buffer_pack(session->out_buffer, "bs", - SSH2_MSG_IGNORE, + type, data); if (rc != SSH_OK){ ssh_set_error_oom(session); @@ -868,12 +875,22 @@ int rc; if (ssh_socket_is_open(session->socket)) { - rc = ssh_buffer_pack(session->out_buffer, - "bbsd", - SSH2_MSG_DEBUG, - always_display != 0 ? 1 : 0, - message, - 0); /* empty language tag */ +#ifdef WITH_SSH1 + if (session->version == 1) { + rc = ssh_buffer_pack(session->out_buffer, + "bs", + SSH_MSG_DEBUG, + message); + } else +#endif /* WITH_SSH1 */ + { + rc = ssh_buffer_pack(session->out_buffer, + "bbsd", + SSH2_MSG_DEBUG, + always_display != 0 ? 1 : 0, + message, + 0); /* empty language tag */ + } if (rc != SSH_OK) { ssh_set_error_oom(session); goto error;