Compare commits

..

12 Commits

Author SHA1 Message Date
Andreas Schneider
4362d76416 build: Prepare libssh 0.4.7 release. 2010-12-27 20:08:58 +01:00
Andreas Schneider
da3b2d68a3 misc: Fixed a possible memory leak.
(cherry picked from commit a0e98f585a)
2010-12-27 18:10:09 +01:00
Andreas Schneider
4638b353d5 sftp: Fixed a memory leak in sftp_xstat.
Thanks to dsc for the bug report.
(cherry picked from commit 7c728acd12)
2010-12-27 17:53:23 +01:00
Vic Lee
a9f3a2f103 socket: Fixed uninitialized fd->revents member.
Signed-off-by: Vic Lee <llyzs@163.com>
2010-12-08 11:40:40 +01:00
Aris Adamantiadis
59f0293576 Fix from Oleksandr Shneyder
http://www.libssh.org/archive/libssh/2010-11/0000005.html
2010-12-07 16:10:34 +01:00
Andreas Schneider
7a314d9149 client: Fixed a typo. 2010-09-29 14:19:45 +02:00
Andreas Schneider
a13c9d4182 misc: Make sure ssh_analyze_banner has proper length checks.
(backported from commit 38359672a5)
2010-09-29 12:15:11 +02:00
Andreas Schneider
93f79c62ef misc: Fixed a possible data overread and crash bug.
(backported from commit 30e22fed6e)
2010-09-29 11:35:53 +02:00
Vic Lee
31fdb4ecf6 socket.c: Fixed setting max_fd which breaks ssh_select().
Signed-off-by: Andreas Schneider <asn@cynapses.org>
2010-09-20 19:24:36 +02:00
Andreas Schneider
0b564c358f include: Fixed some pedantic build warnings. 2010-09-10 21:47:47 +02:00
Andreas Schneider
fb24e68edd session: Fixed a memory leak with session->bindaddr.
(cherry picked from commit 325cc4e395)
2010-09-07 17:37:00 +02:00
Andreas Schneider
b5f095d0b4 misc: Fixed a memory leak.
(cherry picked from commit c1604eff08)
2010-09-07 17:33:29 +02:00
11 changed files with 73 additions and 30 deletions

View File

@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "0") set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "4") set(APPLICATION_VERSION_MINOR "4")
set(APPLICATION_VERSION_PATCH "6") set(APPLICATION_VERSION_PATCH "7")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
# Increment AGE. Set REVISION to 0 # Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes: # If the source code was changed, but there were no interface changes:
# Increment REVISION. # Increment REVISION.
set(LIBRARY_VERSION "4.1.3") set(LIBRARY_VERSION "4.1.4")
set(LIBRARY_SOVERSION "4") set(LIBRARY_SOVERSION "4")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked

View File

@@ -13,7 +13,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
### versions ### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "4") set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "6") set(CPACK_PACKAGE_VERSION_PATCH "7")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

View File

@@ -1,6 +1,17 @@
ChangeLog ChangeLog
========== ==========
version 0.4.7 (released 2010-12-28)
* Fixed a possible memory leak in ssh_get_user_home().
* Fixed a memory leak in sftp_xstat.
* Fixed uninitialized fd->revents member.
* Fixed timout value in ssh_channel_accept().
* Fixed length checks in ssh_analyze_banner().
* Fixed a possible data overread and crash bug.
* Fixed setting max_fd which breaks ssh_select().
* Fixed some pedantic build warnings.
* Fixed a memory leak with session->bindaddr.
version 0.4.6 (released 2010-09-03) version 0.4.6 (released 2010-09-03)
* Added a cleanup function to free the ws2_32 library. * Added a cleanup function to free the ws2_32 library.
* Fixed build with gcc 3.4. * Fixed build with gcc 3.4.

View File

@@ -171,7 +171,7 @@ enum ssh_requests_e {
SSH_REQUEST_CHANNEL_OPEN, SSH_REQUEST_CHANNEL_OPEN,
SSH_REQUEST_CHANNEL, SSH_REQUEST_CHANNEL,
SSH_REQUEST_SERVICE, SSH_REQUEST_SERVICE,
SSH_REQUEST_GLOBAL, SSH_REQUEST_GLOBAL
}; };
enum ssh_channel_type_e { enum ssh_channel_type_e {
@@ -189,7 +189,7 @@ enum ssh_channel_requests_e {
SSH_CHANNEL_REQUEST_SHELL, SSH_CHANNEL_REQUEST_SHELL,
SSH_CHANNEL_REQUEST_ENV, SSH_CHANNEL_REQUEST_ENV,
SSH_CHANNEL_REQUEST_SUBSYSTEM, SSH_CHANNEL_REQUEST_SUBSYSTEM,
SSH_CHANNEL_REQUEST_WINDOW_CHANGE, SSH_CHANNEL_REQUEST_WINDOW_CHANGE
}; };
/* status flags */ /* status flags */
@@ -203,7 +203,7 @@ enum ssh_server_known_e {
SSH_SERVER_KNOWN_OK, SSH_SERVER_KNOWN_OK,
SSH_SERVER_KNOWN_CHANGED, SSH_SERVER_KNOWN_CHANGED,
SSH_SERVER_FOUND_OTHER, SSH_SERVER_FOUND_OTHER,
SSH_SERVER_FILE_NOT_FOUND, SSH_SERVER_FILE_NOT_FOUND
}; };
#ifndef MD5_DIGEST_LEN #ifndef MD5_DIGEST_LEN

View File

@@ -1392,11 +1392,13 @@ static ssh_channel channel_accept(ssh_session session, int channeltype,
iterator = iterator->next; iterator = iterator->next;
} }
} }
if(t>0){
#ifdef _WIN32 #ifdef _WIN32
Sleep(50); /* 50ms */ Sleep(50); /* 50ms */
#else #else
nanosleep(&ts, NULL); nanosleep(&ts, NULL);
#endif #endif
}
} }
return NULL; return NULL;

View File

@@ -110,26 +110,37 @@ static int ssh_analyze_banner(ssh_session session, int *ssh1, int *ssh2) {
const char *banner = session->serverbanner; const char *banner = session->serverbanner;
const char *openssh; const char *openssh;
ssh_log(session, SSH_LOG_RARE, "Analyzing banner: %s", banner); if (banner == NULL) {
ssh_set_error(session, SSH_FATAL, "Invalid banner");
if (strncmp(banner, "SSH-", 4) != 0) { return -1;
ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
return -1;
} }
/* /*
* Typical banners e.g. are: * Typical banners e.g. are:
* SSH-1.5-blah *
* SSH-1.99-blah * SSH-1.5-openSSH_5.4
* SSH-2.0-blah * SSH-1.99-openSSH_3.0
*
* SSH-2.0-something
* 012345678901234567890
*/ */
if (strlen(banner) < 6 ||
strncmp(banner, "SSH-", 4) != 0) {
ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
return -1;
}
ssh_log(session, SSH_LOG_RARE, "Analyzing banner: %s", banner);
switch(banner[4]) { switch(banner[4]) {
case '1': case '1':
*ssh1 = 1; *ssh1 = 1;
if (banner[6] == '9') { if (strlen(banner) > 6) {
*ssh2 = 1; if (banner[6] == '9') {
} else { *ssh2 = 1;
*ssh2 = 0; } else {
*ssh2 = 0;
}
} }
break; break;
case '2': case '2':
@@ -143,13 +154,21 @@ static int ssh_analyze_banner(ssh_session session, int *ssh1, int *ssh2) {
openssh = strstr(banner, "OpenSSH"); openssh = strstr(banner, "OpenSSH");
if (openssh != NULL) { if (openssh != NULL) {
int major, minor; int major, minor;
major = strtol(openssh + 8, (char **) NULL, 10);
minor = strtol(openssh + 10, (char **) NULL, 10); /*
session->openssh = SSH_VERSION_INT(major, minor, 0); * The banner is typical:
ssh_log(session, SSH_LOG_RARE, * OpenSSH_5.4
"We are talking to an OpenSSH server version: %d.%d (%x)", * 012345678901234567890
major, minor, session->openssh); */
if (strlen(openssh) > 9) {
major = strtol(openssh + 8, (char **) NULL, 10);
minor = strtol(openssh + 10, (char **) NULL, 10);
session->openssh = SSH_VERSION_INT(major, minor, 0);
ssh_log(session, SSH_LOG_RARE,
"We are talking to an OpenSSH client version: %d.%d (%x)",
major, minor, session->openssh);
}
} }
return 0; return 0;

View File

@@ -504,7 +504,7 @@ int ssh_mkdir(const char *pathname, mode_t mode) {
* @return The expanded directory, NULL on error. * @return The expanded directory, NULL on error.
*/ */
char *ssh_path_expand_tilde(const char *d) { char *ssh_path_expand_tilde(const char *d) {
char *h, *r; char *h = NULL, *r;
const char *p; const char *p;
size_t ld; size_t ld;
size_t lh = 0; size_t lh = 0;
@@ -548,12 +548,14 @@ char *ssh_path_expand_tilde(const char *d) {
r = malloc(ld + lh + 1); r = malloc(ld + lh + 1);
if (r == NULL) { if (r == NULL) {
SAFE_FREE(h);
return NULL; return NULL;
} }
if (lh > 0) { if (lh > 0) {
memcpy(r, h, lh); memcpy(r, h, lh);
} }
SAFE_FREE(h);
memcpy(r + lh, p, ld + 1); memcpy(r + lh, p, ld + 1);
return r; return r;

View File

@@ -246,6 +246,7 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) {
if (sshbind->bindaddr == NULL) if (sshbind->bindaddr == NULL)
session->bindaddr = NULL; session->bindaddr = NULL;
else { else {
SAFE_FREE(session->bindaddr);
session->bindaddr = strdup(sshbind->bindaddr); session->bindaddr = strdup(sshbind->bindaddr);
if (session->bindaddr == NULL) { if (session->bindaddr == NULL) {
privatekey_free(dsa); privatekey_free(dsa);

View File

@@ -153,6 +153,7 @@ void ssh_free(ssh_session session) {
SAFE_FREE(session->serverbanner); SAFE_FREE(session->serverbanner);
SAFE_FREE(session->clientbanner); SAFE_FREE(session->clientbanner);
SAFE_FREE(session->bindaddr);
SAFE_FREE(session->banner); SAFE_FREE(session->banner);
#ifdef WITH_PCAP #ifdef WITH_PCAP
if(session->pcap_ctx){ if(session->pcap_ctx){

View File

@@ -3123,7 +3123,10 @@ static sftp_attributes sftp_xstat(sftp_session sftp, const char *path,
} }
if (msg->packet_type == SSH_FXP_ATTRS) { if (msg->packet_type == SSH_FXP_ATTRS) {
return sftp_parse_attr(sftp, msg->payload, 0); sftp_attributes attr = sftp_parse_attr(sftp, msg->payload, 0);
sftp_message_free(msg);
return attr;
} else if (msg->packet_type == SSH_FXP_STATUS) { } else if (msg->packet_type == SSH_FXP_STATUS) {
status = parse_status_msg(msg); status = parse_status_msg(msg);
sftp_message_free(msg); sftp_message_free(msg);

View File

@@ -265,7 +265,10 @@ void ssh_socket_fd_set(struct socket *s, fd_set *set, socket_t *max_fd) {
if (s->fd == SSH_INVALID_SOCKET) if (s->fd == SSH_INVALID_SOCKET)
return; return;
FD_SET(s->fd,set); FD_SET(s->fd,set);
if (s->fd >= 0 && s->fd != SSH_INVALID_SOCKET) {
if (s->fd >= 0 &&
s->fd >= *max_fd &&
s->fd != SSH_INVALID_SOCKET) {
*max_fd = s->fd + 1; *max_fd = s->fd + 1;
} }
} }
@@ -489,6 +492,7 @@ int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
fd->fd = s->fd; fd->fd = s->fd;
fd->events = 0; fd->events = 0;
fd->revents = 0;
if (!s->data_to_read) { if (!s->data_to_read) {
fd->events |= POLLIN; fd->events |= POLLIN;