Hello community, here is the log from the commit of package libssh for openSUSE:Factory checked in at Tue Sep 6 15:35:37 CEST 2011.
-------- --- libssh/libssh.changes 2011-05-31 16:50:18.000000000 +0200 +++ /mounts/work_src_done/STABLE/libssh/libssh.changes 2011-09-06 05:38:22.000000000 +0200 @@ -1,0 +2,24 @@ +Tue Sep 6 03:36:48 UTC 2011 - crrodrig...@opensuse.org + +- Build with OPENSSL_LOAD_CONF so we respect user's choice + of which "openssl engine" to use for crypto (aes-ni,intel-accel) + +------------------------------------------------------------------- +Tue Aug 9 15:12:39 UTC 2011 - a...@cryptomilk.org + +- Update to version 0.5.1 + * Added checks for NULL pointers in string.c. + * Set the channel max packet size to 32768. + * Don't (de)compress empty buffers. + * Fixed ssh_scp_write so it works when doing recursive copy. + * Fixed another source of endless wait. + * Fixed an endless loop in case of a channel_open error. + * Fixed session timeout handling. + * Fixed ssh_channel_from_local() loop. + * Fixed permissions of scp example when we copy a file. + * Workaround ssh_get_user_home_dir on LDAP users. + * Added pkg-config support for libssh_threads. + * Fixed compilation without server and sftp modes. + * Fix static .lib overwriting on Windows. + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- libssh-0.5.0.tar.bz2 New: ---- libssh-0.5.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libssh.spec ++++++ --- /var/tmp/diff_new_pack.iJ8Kat/_old 2011-09-06 15:24:57.000000000 +0200 +++ /var/tmp/diff_new_pack.iJ8Kat/_new 2011-09-06 15:24:57.000000000 +0200 @@ -23,7 +23,7 @@ BuildRequires: cmake doxygen gcc-c++ openssl-devel License: LGPL v2.1 or later Group: System/Libraries -Version: 0.5.0 +Version: 0.5.1 Release: 1 Summary: SSH library Source0: %{name}-%{version}.tar.bz2 @@ -119,7 +119,7 @@ fi pushd build cmake \ - -DCMAKE_C_FLAGS:STRING="%{optflags}" \ + -DCMAKE_C_FLAGS:STRING="%{optflags} -DOPENSSL_LOAD_CONF" \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_SKIP_RPATH=ON \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ @@ -162,6 +162,7 @@ %{_libdir}/libssh.so %{_libdir}/libssh_threads.so %{_libdir}/pkgconfig/libssh.pc +%{_libdir}/pkgconfig/libssh_threads.pc %files devel-doc %defattr(-,root,root) ++++++ libssh-0.5.0.tar.bz2 -> libssh-0.5.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/CMakeLists.txt new/libssh-0.5.1/CMakeLists.txt --- old/libssh-0.5.0/CMakeLists.txt 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/CMakeLists.txt 2011-08-09 14:48:21.000000000 +0200 @@ -8,7 +8,7 @@ set(APPLICATION_VERSION_MAJOR "0") set(APPLICATION_VERSION_MINOR "5") -set(APPLICATION_VERSION_PATCH "0") +set(APPLICATION_VERSION_PATCH "1") 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.2.0") +set(LIBRARY_VERSION "4.2.1") set(LIBRARY_SOVERSION "4") # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked @@ -78,9 +78,11 @@ # pkg-config file configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc) +configure_file(libssh_threads.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh_threads.pc) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc + ${CMAKE_CURRENT_BINARY_DIR}/libssh_threads.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig COMPONENT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/CPackConfig.cmake new/libssh-0.5.1/CPackConfig.cmake --- old/libssh-0.5.0/CPackConfig.cmake 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/CPackConfig.cmake 2011-08-09 14:48:21.000000000 +0200 @@ -13,7 +13,7 @@ ### versions set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MINOR "5") -set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_VERSION_PATCH "1") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/ChangeLog new/libssh-0.5.1/ChangeLog --- old/libssh-0.5.0/ChangeLog 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/ChangeLog 2011-08-09 14:48:21.000000000 +0200 @@ -1,6 +1,21 @@ ChangeLog ========== +version 0.5.1 (released 2011-08-09) + * Added checks for NULL pointers in string.c. + * Set the channel max packet size to 32768. + * Don't (de)compress empty buffers. + * Fixed ssh_scp_write so it works when doing recursive copy. + * Fixed another source of endless wait. + * Fixed an endless loop in case of a channel_open error. + * Fixed session timeout handling. + * Fixed ssh_channel_from_local() loop. + * Fixed permissions of scp example when we copy a file. + * Workaround ssh_get_user_home_dir on LDAP users. + * Added pkg-config support for libssh_threads. + * Fixed compilation without server and sftp modes. + * Fix static .lib overwriting on Windows. + version 0.5.0 (released 2011-06-01) * Added ssh_ prefix to all functions. * Added complete Windows support. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/ConfigureChecks.cmake new/libssh-0.5.1/ConfigureChecks.cmake --- old/libssh-0.5.0/ConfigureChecks.cmake 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/ConfigureChecks.cmake 2011-08-09 14:48:21.000000000 +0200 @@ -119,6 +119,7 @@ check_function_exists(select HAVE_SELECT) check_function_exists(cfmakeraw HAVE_CFMAKERAW) check_function_exists(regcomp HAVE_REGCOMP) + check_function_exists(ntohll HAVE_NTOHLL) endif (UNIX) set(LIBSSH_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "libssh required system libraries") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/config.h.cmake new/libssh-0.5.1/config.h.cmake --- old/libssh-0.5.0/config.h.cmake 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/config.h.cmake 2011-08-09 14:48:21.000000000 +0200 @@ -80,6 +80,9 @@ /* Define to 1 if you have the `clock_gettime' function. */ #cmakedefine HAVE_CLOCK_GETTIME 1 +/* Define to 1 if you have the `ntohll' function. */ +#cmakedefine HAVE_NTOHLL 1 + /*************************** LIBRARIES ***************************/ /* Define to 1 if you have the `crypto' library (-lcrypto). */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/examples/libssh_scp.c new/libssh-0.5.1/examples/libssh_scp.c --- old/libssh-0.5.0/examples/libssh_scp.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/examples/libssh_scp.c 2011-08-09 14:48:21.000000000 +0200 @@ -182,7 +182,7 @@ fd=fileno(src->file); fstat(fd,&s); size=s.st_size; - mode = s.st_mode & S_IFMT; + mode = s.st_mode & ~S_IFMT; filename=ssh_basename(src->path); } else { size=0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/include/libssh/libssh.h new/libssh-0.5.1/include/libssh/libssh.h --- old/libssh-0.5.0/include/libssh/libssh.h 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/include/libssh/libssh.h 2011-08-09 14:48:21.000000000 +0200 @@ -79,7 +79,7 @@ /* libssh version */ #define LIBSSH_VERSION_MAJOR 0 #define LIBSSH_VERSION_MINOR 5 -#define LIBSSH_VERSION_MICRO 0 +#define LIBSSH_VERSION_MICRO 1 #define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ LIBSSH_VERSION_MINOR, \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/libssh_threads.pc.cmake new/libssh-0.5.1/libssh_threads.pc.cmake --- old/libssh-0.5.0/libssh_threads.pc.cmake 1970-01-01 01:00:00.000000000 +0100 +++ new/libssh-0.5.1/libssh_threads.pc.cmake 2011-08-09 14:48:21.000000000 +0200 @@ -0,0 +1,5 @@ +Name: ${APPLICATION_NAME}_threads +Description: The SSH Library Thread Extension +Version: ${APPLICATION_VERSION} +Libs: -L${LIB_INSTALL_DIR} -lssh_threads +Cflags: -I${INCLUDE_INSTALL_DIR} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/CMakeLists.txt new/libssh-0.5.1/src/CMakeLists.txt --- old/libssh-0.5.0/src/CMakeLists.txt 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/CMakeLists.txt 2011-08-09 14:48:21.000000000 +0200 @@ -184,6 +184,11 @@ if (WITH_STATIC_LIB) add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS}) + if (MSVC) + set(OUTPUT_SUFFIX static) + else (MSVC) + set(OUTPUT_SUFFIX ) + endif (MSVC) set_target_properties( ${LIBSSH_STATIC_LIBRARY} PROPERTIES @@ -193,6 +198,8 @@ ${LIBRARY_SOVERSION} OUTPUT_NAME ssh + ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SUFFIX} ) if (WIN32) @@ -208,7 +215,7 @@ TARGETS ${LIBSSH_STATIC_LIBRARY} DESTINATION - ${LIB_INSTALL_DIR} + ${LIB_INSTALL_DIR}/${OUTPUT_SUFFIX} COMPONENT libraries ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/auth.c new/libssh-0.5.1/src/auth.c --- old/libssh-0.5.0/src/auth.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/auth.c 2011-08-09 14:48:21.000000000 +0200 @@ -62,23 +62,23 @@ * again is necessary */ static int ask_userauth(ssh_session session) { - int rc = 0; + int rc = 0; - enter_function(); - do { - rc=ssh_service_request(session,"ssh-userauth"); - if(ssh_is_blocking(session)){ - if(rc==SSH_AGAIN) - ssh_handle_packets(session,-1); - } else { - /* nonblocking */ - ssh_handle_packets(session,0); - rc=ssh_service_request(session,"ssh-userauth"); - break; - } - } while(rc==SSH_AGAIN); - leave_function(); - return rc; + enter_function(); + do { + rc = ssh_service_request(session,"ssh-userauth"); + if (ssh_is_blocking(session)) { + if(rc == SSH_AGAIN) + ssh_handle_packets(session, -2); + } else { + /* nonblocking */ + ssh_handle_packets(session, 0); + rc = ssh_service_request(session, "ssh-userauth"); + break; + } + } while (rc == SSH_AGAIN); + leave_function(); + return rc; } /** @@ -254,7 +254,7 @@ enter_function(); if(ssh_is_blocking(session)){ - if(ssh_handle_packets_termination(session,-1,auth_status_termination, + if(ssh_handle_packets_termination(session, -2, auth_status_termination, session) == SSH_ERROR){ leave_function(); return SSH_AUTH_ERROR; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/auth1.c new/libssh-0.5.1/src/auth1.c --- old/libssh-0.5.0/src/auth1.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/auth1.c 2011-08-09 14:48:21.000000000 +0200 @@ -38,7 +38,7 @@ enter_function(); /* wait for a packet */ while(session->auth_state == SSH_AUTH_STATE_NONE) - if (ssh_handle_packets(session,-1) != SSH_OK) + if (ssh_handle_packets(session, -2) != SSH_OK) break; ssh_log(session,SSH_LOG_PROTOCOL,"Auth state : %d",session->auth_state); leave_function(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/channels.c new/libssh-0.5.1/src/channels.c --- old/libssh-0.5.0/src/channels.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/channels.c 2011-08-09 14:48:21.000000000 +0200 @@ -48,6 +48,14 @@ #define WINDOWBASE 128000 #define WINDOWLIMIT (WINDOWBASE/2) +/* + * All implementations MUST be able to process packets with an + * uncompressed payload length of 32768 bytes or less and a total packet + * size of 35000 bytes or less. + */ +#define CHANNEL_MAX_PACKET 32768 +#define CHANNEL_INITIAL_WINDOW 64000 + /** * @defgroup libssh_channel The SSH channel functions * @ingroup libssh @@ -284,7 +292,11 @@ /* Todo: fix this into a correct loop */ /* wait until channel is opened by server */ while(channel->state == SSH_CHANNEL_STATE_NOT_OPEN){ - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); + if (session->session_state == SSH_SESSION_STATE_ERROR) { + err = SSH_ERROR; + break; + } } if(channel->state == SSH_CHANNEL_STATE_OPEN) err=SSH_OK; @@ -292,24 +304,25 @@ return err; } -/* get ssh channel from local session? */ +/* return channel with corresponding local id, or NULL if not found */ ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id) { - ssh_channel initchan = session->channels; - ssh_channel channel; - - /* We assume we are always the local */ - if (initchan == NULL) { - return NULL; - } + ssh_channel initchan = session->channels; + ssh_channel channel = initchan; - for (channel = initchan; channel->local_channel != id; - channel=channel->next) { - if (channel->next == initchan) { - return NULL; + for (;;) { + if (channel == NULL) { + return NULL; + } + if (channel->local_channel == id) { + return channel; + } + if (channel->next == initchan) { + return NULL; + } + channel = channel->next; } - } - return channel; + return NULL; } /** @@ -877,7 +890,11 @@ } #endif - return channel_open(channel,"session",64000,32000,NULL); + return channel_open(channel, + "session", + CHANNEL_INITIAL_WINDOW, + CHANNEL_MAX_PACKET, + NULL); } /** @@ -952,7 +969,11 @@ goto error; } - rc = channel_open(channel, "direct-tcpip", 64000, 32000, payload); + rc = channel_open(channel, + "direct-tcpip", + CHANNEL_INITIAL_WINDOW, + CHANNEL_MAX_PACKET, + payload); error: ssh_buffer_free(payload); @@ -1404,7 +1425,12 @@ return SSH_OK; } while(channel->request_state == SSH_CHANNEL_REQ_STATE_PENDING){ - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); + if(session->session_state == SSH_SESSION_STATE_ERROR) { + channel->request_state = SSH_CHANNEL_REQ_STATE_ERROR; + break; + } + } /* we received something */ switch (channel->request_state){ @@ -1721,7 +1747,7 @@ for (t = timeout_ms; t >= 0; t -= 50) { - ssh_handle_packets(session,50); + ssh_handle_packets(session, 50); if (session->ssh_message_list) { iterator = ssh_list_get_iterator(session->ssh_message_list); @@ -1878,7 +1904,7 @@ return SSH_OK; } while(session->global_req_state == SSH_CHANNEL_REQ_STATE_PENDING){ - rc=ssh_handle_packets(session,-1); + rc=ssh_handle_packets(session, -2); if(rc==SSH_ERROR){ session->global_req_state = SSH_CHANNEL_REQ_STATE_ERROR; break; @@ -2262,7 +2288,7 @@ leave_function(); return 0; } - ssh_handle_packets(channel->session, -1); + ssh_handle_packets(channel->session, -2); } while (r == 0); } while(total < count){ @@ -2360,7 +2386,7 @@ break; } - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); } len = buffer_get_rest_len(stdbuf); @@ -2450,7 +2476,7 @@ } if (buffer_get_rest_len(stdbuf) == 0 && channel->remote_eof == 0) { - if (ssh_handle_packets(channel->session,0)==SSH_ERROR) { + if (ssh_handle_packets(channel->session, 0)==SSH_ERROR) { leave_function(); return SSH_ERROR; } @@ -2497,7 +2523,7 @@ while ((channel->remote_eof == 0 || channel->exit_status == -1) && channel->session->alive) { /* Parse every incoming packet */ - if (ssh_handle_packets(channel->session,-1) != SSH_OK) { + if (ssh_handle_packets(channel->session, -2) != SSH_OK) { return -1; } /* XXX We should actually wait for a close packet and not a close @@ -2532,7 +2558,7 @@ chan = rchans[i]; while (ssh_channel_is_open(chan) && ssh_socket_data_available(chan->session->socket)) { - ssh_handle_packets(chan->session,-1); + ssh_handle_packets(chan->session, -2); } if ((chan->stdout_buffer && buffer_get_rest_len(chan->stdout_buffer) > 0) || @@ -2803,7 +2829,11 @@ goto error; } - rc = channel_open(channel, "forwarded-tcpip", 64000, 32000, payload); + rc = channel_open(channel, + "forwarded-tcpip", + CHANNEL_INITIAL_WINDOW, + CHANNEL_MAX_PACKET, + payload); error: ssh_buffer_free(payload); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/client.c new/libssh-0.5.1/src/client.c --- old/libssh-0.5.0/src/client.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/client.c 2011-08-09 14:48:21.000000000 +0200 @@ -684,19 +684,21 @@ session->alive = 1; ssh_log(session,SSH_LOG_PROTOCOL,"Socket connecting, now waiting for the callbacks to work"); pending: - session->pending_call_state=SSH_PENDING_CALL_CONNECT; - if(ssh_is_blocking(session)) { - int timeout = session->timeout * 1000 + session->timeout_usec; - if (timeout <= 0) - timeout = -1; - ssh_handle_packets_termination(session,timeout,ssh_connect_termination,session); - if(!ssh_connect_termination(session)){ - ssh_set_error(session,SSH_FATAL,"Timeout connecting to %s",session->host); - session->session_state = SSH_SESSION_STATE_ERROR; - } - } + session->pending_call_state=SSH_PENDING_CALL_CONNECT; + if(ssh_is_blocking(session)) { + int timeout = (session->timeout * 1000) + (session->timeout_usec / 1000); + if (timeout == 0) { + timeout = 10 * 1000; + } + ssh_log(session,SSH_LOG_PACKET,"ssh_connect: Actual timeout : %d", timeout); + ssh_handle_packets_termination(session, timeout, ssh_connect_termination, session); + if(!ssh_connect_termination(session)){ + ssh_set_error(session,SSH_FATAL,"Timeout connecting to %s",session->host); + session->session_state = SSH_SESSION_STATE_ERROR; + } + } else - ssh_handle_packets_termination(session,0,ssh_connect_termination, session); + ssh_handle_packets_termination(session, 0, ssh_connect_termination, session); ssh_log(session,SSH_LOG_PACKET,"ssh_connect: Actual state : %d",session->session_state); if(!ssh_is_blocking(session) && !ssh_connect_termination(session)){ leave_function(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/kex.c new/libssh-0.5.1/src/kex.c --- old/libssh-0.5.0/src/kex.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/kex.c 2011-08-09 14:48:21.000000000 +0200 @@ -814,14 +814,14 @@ ssh_log(session, SSH_LOG_PROTOCOL, "Waiting for a SSH_SMSG_PUBLIC_KEY"); /* Here the callback is called */ while(session->session_state==SSH_SESSION_STATE_INITIAL_KEX){ - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); } if(session->session_state==SSH_SESSION_STATE_ERROR) goto error; ssh_log(session, SSH_LOG_PROTOCOL, "Waiting for a SSH_SMSG_SUCCESS"); /* Waiting for SSH_SMSG_SUCCESS */ while(session->session_state==SSH_SESSION_STATE_KEXINIT_RECEIVED){ - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); } if(session->session_state==SSH_SESSION_STATE_ERROR) goto error; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/messages.c new/libssh-0.5.1/src/messages.c --- old/libssh-0.5.0/src/messages.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/messages.c 2011-08-09 14:48:21.000000000 +0200 @@ -69,6 +69,26 @@ return msg; } +#ifndef WITH_SERVER + +/* Reduced version of the reply default that only reply with + * SSH_MSG_UNIMPLEMENTED + */ +static int ssh_message_reply_default(ssh_message msg) { + ssh_log(msg->session, SSH_LOG_FUNCTIONS, "Reporting unknown packet"); + + if (buffer_add_u8(msg->session->out_buffer, SSH2_MSG_UNIMPLEMENTED) < 0) + goto error; + if (buffer_add_u32(msg->session->out_buffer, + htonl(msg->session->recv_seq-1)) < 0) + goto error; + return packet_send(msg->session); + error: + return SSH_ERROR; +} + +#endif + static int ssh_execute_message_callback(ssh_session session, ssh_message msg) { int ret; if(session->ssh_message_callback != NULL) { @@ -161,7 +181,7 @@ session->ssh_message_list = ssh_list_new(); } do { - if (ssh_handle_packets(session,-1) == SSH_ERROR) { + if (ssh_handle_packets(session, -2) == SSH_ERROR) { leave_function(); return NULL; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/misc.c new/libssh-0.5.1/src/misc.c --- old/libssh-0.5.0/src/misc.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/misc.c 2011-08-09 14:48:21.000000000 +0200 @@ -215,7 +215,8 @@ rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf); if (rc != 0) { - return NULL; + szPath=getenv("HOME"); + return szPath ? strdup(szPath) : NULL; } szPath = strdup(pwd.pw_dir); @@ -286,18 +287,20 @@ #endif /* _WIN32 */ +#ifndef HAVE_NTOHLL uint64_t ntohll(uint64_t a) { #ifdef WORDS_BIGENDIAN return a; -#else +#else /* WORDS_BIGENDIAN */ uint32_t low = (uint32_t)(a & 0xffffffff); uint32_t high = (uint32_t)(a >> 32); low = ntohl(low); high = ntohl(high); return ((((uint64_t) low) << 32) | ( high)); -#endif +#endif /* WORDS_BIGENDIAN */ } +#endif /* HAVE_NTOHLL */ char *ssh_lowercase(const char* str) { char *new, *p; @@ -937,15 +940,15 @@ * @param[in] ts pointer to an existing timestamp * @param[in] timeout timeout in milliseconds. Negative values mean infinite * timeout - * @returns remaining time in milliseconds, 0 if elapsed, -1 if never. + * @returns remaining time in milliseconds, 0 if elapsed, -1 if never, + * -2 if option-set-timeout. */ int ssh_timeout_update(struct ssh_timestamp *ts, int timeout){ struct ssh_timestamp now; int ms, ret; - if(timeout == 0) - return 0; - if(timeout==-1) - return -1; + if (timeout <= 0) { + return timeout; + } ssh_timestamp_init(&now); ms = ssh_timestamp_difference(ts,&now); if(ms < 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/packet.c new/libssh-0.5.1/src/packet.c --- old/libssh-0.5.0/src/packet.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/packet.c 2011-08-09 14:48:21.000000000 +0200 @@ -255,7 +255,9 @@ "After padding, %d bytes left in buffer", buffer_get_rest_len(session->in_buffer)); #if defined(HAVE_LIBZ) && defined(WITH_LIBZ) - if (session->current_crypto && session->current_crypto->do_compress_in) { + if (session->current_crypto + && session->current_crypto->do_compress_in + && buffer_get_rest_len(session->in_buffer)) { ssh_log(session, SSH_LOG_PACKET, "Decompressing in_buffer ..."); if (decompress_buffer(session, session->in_buffer,MAX_PACKET_LEN) < 0) { goto error; @@ -457,7 +459,9 @@ "Writing on the wire a packet having %u bytes before", currentlen); #if defined(HAVE_LIBZ) && defined(WITH_LIBZ) - if (session->current_crypto && session->current_crypto->do_compress_out) { + if (session->current_crypto + && session->current_crypto->do_compress_out + && buffer_get_rest_len(session->out_buffer)) { ssh_log(session, SSH_LOG_PACKET, "Compressing out_buffer ..."); if (compress_buffer(session,session->out_buffer) < 0) { goto error; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/poll.c new/libssh-0.5.1/src/poll.c --- old/libssh-0.5.0/src/poll.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/poll.c 2011-08-09 14:48:21.000000000 +0200 @@ -608,11 +608,16 @@ if (!ctx->pollfds[i].revents) { i++; } else { + int ret; + p = ctx->pollptrs[i]; fd = ctx->pollfds[i].fd; revents = ctx->pollfds[i].revents; - if (p->cb(p, fd, revents, p->cb_data) < 0) { + if (p->cb && (ret = p->cb(p, fd, revents, p->cb_data)) < 0) { + if (ret == -2) { + return -1; + } /* the poll was removed, reload the used counter and start again */ used = ctx->polls_used; i=0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/scp.c new/libssh-0.5.1/src/scp.c --- old/libssh-0.5.0/src/scp.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/scp.c 2011-08-09 14:48:21.000000000 +0200 @@ -380,8 +380,8 @@ */ int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len){ int w; - //int r; - //uint8_t code; + int r; + uint8_t code; if(scp==NULL) return SSH_ERROR; if(scp->state != SSH_SCP_WRITE_WRITING){ @@ -400,19 +400,27 @@ //return=channel_get_exit_status(scp->channel); return SSH_ERROR; } - /* Check if we arrived at end of file */ - if(scp->processed == scp->filelen) { -/* r=channel_read(scp->channel,&code,1,0); - if(r==SSH_ERROR){ - scp->state=SSH_SCP_ERROR; + /* Far end sometimes send a status message, which we need to read + * and handle */ + r = ssh_channel_poll(scp->channel,0); + if(r > 0){ + r = ssh_channel_read(scp->channel, &code, 1, 0); + if(r == SSH_ERROR){ + return SSH_ERROR; + } + if(code == 1 || code == 2){ + ssh_set_error(scp->session,SSH_REQUEST_DENIED, "SCP: Error: status code %i received", code); return SSH_ERROR; } - if(code != 0){ - ssh_set_error(scp->session,SSH_FATAL, "scp status code %ud not valid", code); - scp->state=SSH_SCP_ERROR; + } + /* Check if we arrived at end of file */ + if(scp->processed == scp->filelen) { + code = 0; + w = ssh_channel_write(scp->channel, &code, 1); + if(w == SSH_ERROR){ + scp->state = SSH_SCP_ERROR; return SSH_ERROR; } -*/ scp->processed=scp->filelen=0; scp->state=SSH_SCP_WRITE_INITED; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/server.c new/libssh-0.5.1/src/server.c --- old/libssh-0.5.0/src/server.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/server.c 2011-08-09 14:48:21.000000000 +0200 @@ -479,7 +479,7 @@ * loop until SSH_SESSION_STATE_BANNER_RECEIVED or * SSH_SESSION_STATE_ERROR */ - ssh_handle_packets(session,-1); + ssh_handle_packets(session, -2); ssh_log(session,SSH_LOG_PACKET, "ssh_handle_key_exchange: Actual state : %d", session->session_state); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/session.c new/libssh-0.5.1/src/session.c --- old/libssh-0.5.0/src/session.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/session.c 2011-08-09 14:48:21.000000000 +0200 @@ -404,6 +404,17 @@ ssh_socket_set_except(session->socket); } +static int ssh_make_milliseconds(long sec, long usec) { + int res = usec ? (usec / 1000) : 0; + res += (sec * 1000); + if (res == 0) { + res = 10 * 1000; /* use a reasonable default value in case + * SSH_OPTIONS_TIMEOUT is not set in options. */ + } + + return res; +} + /** * @internal * @@ -415,38 +426,56 @@ * @param[in] session The session handle to use. * * @param[in] timeout Set an upper limit on the time for which this function - * will block, in milliseconds. Specifying a negative value - * means an infinite timeout. This parameter is passed to - * the poll() function. + * will block, in milliseconds. Specifying -1 + * means an infinite timeout. + * Specifying -2 means to use the timeout specified in + * options. 0 means poll will return immediately. This + * parameter is passed to the poll() function. * * @return SSH_OK on success, SSH_ERROR otherwise. */ int ssh_handle_packets(ssh_session session, int timeout) { - ssh_poll_handle spoll_in,spoll_out; - ssh_poll_ctx ctx; - int rc; - if(session==NULL || session->socket==NULL) - return SSH_ERROR; - enter_function(); - spoll_in=ssh_socket_get_poll_handle_in(session->socket); - spoll_out=ssh_socket_get_poll_handle_out(session->socket); - if(session->server) - ssh_poll_add_events(spoll_in, POLLIN); - ctx=ssh_poll_get_ctx(spoll_in); - if(ctx==NULL){ - ctx=ssh_poll_get_default_ctx(session); - ssh_poll_ctx_add(ctx,spoll_in); - if(spoll_in != spoll_out) - ssh_poll_ctx_add(ctx,spoll_out); - } - rc = ssh_poll_ctx_dopoll(ctx,timeout); - if(rc == SSH_ERROR) - session->session_state = SSH_SESSION_STATE_ERROR; - leave_function(); - if (session->session_state != SSH_SESSION_STATE_ERROR) - return SSH_OK; - else - return SSH_ERROR; + ssh_poll_handle spoll_in,spoll_out; + ssh_poll_ctx ctx; + int tm = timeout; + int rc; + + if (session == NULL || session->socket == NULL) { + return SSH_ERROR; + } + enter_function(); + + spoll_in = ssh_socket_get_poll_handle_in(session->socket); + spoll_out = ssh_socket_get_poll_handle_out(session->socket); + if (session->server) { + ssh_poll_add_events(spoll_in, POLLIN); + } + ctx = ssh_poll_get_ctx(spoll_in); + + if (!ctx) { + ctx = ssh_poll_get_default_ctx(session); + ssh_poll_ctx_add(ctx, spoll_in); + if (spoll_in != spoll_out) { + ssh_poll_ctx_add(ctx, spoll_out); + } + } + + if (timeout == -2) { + tm = ssh_make_milliseconds(session->timeout, session->timeout_usec); + } + rc = ssh_poll_ctx_dopoll(ctx, tm); + + if (rc == SSH_ERROR) { + session->session_state = SSH_SESSION_STATE_ERROR; + } + + leave_function(); + + if (session->session_state == SSH_SESSION_STATE_ERROR) { + return SSH_ERROR; + } + + return SSH_OK; } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/socket.c new/libssh-0.5.1/src/socket.c --- old/libssh-0.5.0/src/socket.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/socket.c 2011-08-09 14:48:21.000000000 +0200 @@ -246,32 +246,34 @@ s->read_wontblock=1; r=ssh_socket_unbuffered_read(s,buffer,sizeof(buffer)); if(r<0){ - if(p != NULL) { - ssh_poll_remove_events(p, POLLIN); - } + if(p != NULL) { + ssh_poll_remove_events(p, POLLIN); + } if(s->callbacks && s->callbacks->exception){ s->callbacks->exception( SSH_SOCKET_EXCEPTION_ERROR, s->last_errno,s->callbacks->userdata); - /* p may have been freed, so don't use it - * anymore in this function */ - p = NULL; + /* p may have been freed, so don't use it + * anymore in this function */ + p = NULL; + return -2; } } if(r==0){ - if(p != NULL) { - ssh_poll_remove_events(p, POLLIN); - } - if(p != NULL) { - ssh_poll_remove_events(p, POLLIN); - } + if(p != NULL) { + ssh_poll_remove_events(p, POLLIN); + } + if(p != NULL) { + ssh_poll_remove_events(p, POLLIN); + } if(s->callbacks && s->callbacks->exception){ s->callbacks->exception( SSH_SOCKET_EXCEPTION_EOF, 0,s->callbacks->userdata); - /* p may have been freed, so don't use it - * anymore in this function */ - p = NULL; + /* p may have been freed, so don't use it + * anymore in this function */ + p = NULL; + return -2; } } if(r>0){ @@ -282,9 +284,9 @@ buffer_get_rest_len(s->in_buffer), s->callbacks->userdata); buffer_pass_bytes(s->in_buffer,r); - /* p may have been freed, so don't use it - * anymore in this function */ - p = NULL; + /* p may have been freed, so don't use it + * anymore in this function */ + p = NULL; } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/string.c new/libssh-0.5.1/src/string.c --- old/libssh-0.5.0/src/string.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/string.c 2011-08-09 14:48:21.000000000 +0200 @@ -21,6 +21,7 @@ * MA 02111-1307, USA. */ +#include <errno.h> #include <stdlib.h> #include <string.h> @@ -91,8 +92,15 @@ * @note The nul byte is not copied nor counted in the ouput string. */ struct ssh_string_struct *ssh_string_from_char(const char *what) { - struct ssh_string_struct *ptr = NULL; - size_t len = strlen(what); + struct ssh_string_struct *ptr; + size_t len; + + if(what == NULL) { + errno = EINVAL; + return NULL; + } + + len = strlen(what); ptr = malloc(4 + len); if (ptr == NULL) { @@ -133,7 +141,7 @@ char *ssh_string_to_char(struct ssh_string_struct *s) { size_t len; char *new; - if(s==NULL) + if(s==NULL || s->string == NULL) return NULL; len = ntohl(s->size) + 1; new = malloc(len); @@ -164,7 +172,12 @@ * @return Newly allocated copy of the string, NULL on error. */ struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) { - struct ssh_string_struct *new = malloc(ntohl(s->size) + 4); + struct ssh_string_struct *new; + + if(s == NULL || s->string == NULL) { + return NULL; + } + new = malloc(ntohl(s->size) + 4); if (new == NULL) { return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/src/threads/CMakeLists.txt new/libssh-0.5.1/src/threads/CMakeLists.txt --- old/libssh-0.5.0/src/threads/CMakeLists.txt 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/src/threads/CMakeLists.txt 2011-08-09 14:48:21.000000000 +0200 @@ -86,6 +86,12 @@ if (WITH_STATIC_LIB) add_library(${LIBSSH_THREADS_STATIC_LIBRARY} STATIC ${libssh_threads_SRCS}) + if (MSVC) + set(OUTPUT_SUFFIX static) + else (MSVC) + set(OUTPUT_SUFFIX ) + endif (MSVC) + set_target_properties( ${LIBSSH_THREADS_STATIC_LIBRARY} PROPERTIES @@ -93,15 +99,26 @@ ${LIBRARY_VERSION} SOVERSION ${LIBRARY_SOVERSION} - COMPILE_FLAGS - "-DLIBSSH_STATIC" + OUTPUT_NAME + ssh_threads + ARCHIVE_OUTPUT_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SUFFIX} + ) + + if (WIN32) + set_target_properties( + ${LIBSSH_THREADS_STATIC_LIBRARY} + PROPERTIES + COMPILE_FLAGS + "-DLIBSSH_STATIC" ) + endif (WIN32) install( TARGETS ${LIBSSH_THREADS_STATIC_LIBRARY} DESTINATION - ${LIB_INSTALL_DIR} + ${LIB_INSTALL_DIR}/${OUTPUT_SUFFIX} COMPONENT libraries ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libssh-0.5.0/tests/torture.c new/libssh-0.5.1/tests/torture.c --- old/libssh-0.5.0/tests/torture.c 2011-05-31 16:29:52.000000000 +0200 +++ new/libssh-0.5.1/tests/torture.c 2011-08-09 14:48:21.000000000 +0200 @@ -216,6 +216,8 @@ return NULL; } +#ifdef WITH_SFTP + struct torture_sftp *torture_sftp_session(ssh_session session) { struct torture_sftp *t; char template[] = "/tmp/ssh_torture_XXXXXX"; @@ -282,7 +284,10 @@ free(t->testdir); free(t); } -#endif +#endif /* WITH_SFTP */ + +#endif /* _WIN32 */ + int torture_libssh_verbosity(void){ return verbosity; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org