Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit aa88f0b

Browse files
committed
Merge commit '8a2deeb3ccb18e99c78fb881ff4fe8cb516d2318'
2 parents a5b9bd9 + 8a2deeb commit aa88f0b

18 files changed

Lines changed: 364 additions & 305 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
88

99
set(APPLICATION_VERSION_MAJOR "0")
1010
set(APPLICATION_VERSION_MINOR "7")
11-
set(APPLICATION_VERSION_PATCH "3")
11+
set(APPLICATION_VERSION_PATCH "4")
1212

1313
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
1414

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
ChangeLog
22
==========
3+
version 0.7.4 (released 2017-02-03)
4+
* Added id_ed25519 to the default identity list
5+
* Fixed sftp EOF packet handling
6+
* Fixed ssh_send_banner() to confirm with RFC 4253
7+
* Fixed some memory leaks
38

49
version 0.7.3 (released 2016-01-23)
510
* Fixed CVE-2016-0739

ConfigureChecks.cmake

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,21 @@ endif (NOT WITH_GCRYPT)
111111

112112
check_function_exists(isblank HAVE_ISBLANK)
113113
check_function_exists(strncpy HAVE_STRNCPY)
114+
check_function_exists(strtoull HAVE_STRTOULL)
114115

115-
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
116-
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
116+
if (NOT WIN32)
117+
check_function_exists(vsnprintf HAVE_VSNPRINTF)
118+
check_function_exists(snprintf HAVE_SNPRINTF)
119+
endif (NOT WIN32)
117120

118121
if (WIN32)
119-
check_function_exists(_strtoui64 HAVE__STRTOUI64)
120-
check_function_exists(strtoull HAVE_STRTOULL)
121-
check_function_exists(__strtoull HAVE___STRTOULL)
122+
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
123+
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
122124

123-
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
124-
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
125-
check_function_exists(_snprintf HAVE__SNPRINTF)
126-
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
125+
check_symbol_exists(_vsnprintf_s "stdio.h" HAVE__VSNPRINTF_S)
126+
check_symbol_exists(_vsnprintf "stdio.h" HAVE__VSNPRINTF)
127+
check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF)
128+
check_symbol_exists(_snprintf_s "stdio.h" HAVE__SNPRINTF_S)
127129

128130
if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
129131
check_symbol_exists(ntohll winsock2.h HAVE_NTOHLL)
@@ -137,6 +139,8 @@ if (WIN32)
137139
set(CMAKE_REQUIRED_LIBRARIES)
138140
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
139141

142+
check_function_exists(_strtoui64 HAVE__STRTOUI64)
143+
140144
set(HAVE_SELECT TRUE)
141145
else (WIN32)
142146
check_function_exists(poll HAVE_POLL)
@@ -174,7 +178,6 @@ if (UNIX)
174178

175179
check_library_exists(util forkpty "" HAVE_LIBUTIL)
176180
check_function_exists(cfmakeraw HAVE_CFMAKERAW)
177-
check_function_exists(strtoull HAVE_STRTOULL)
178181
check_function_exists(__strtoull HAVE___STRTOULL)
179182
endif (UNIX)
180183

README

Lines changed: 3 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -33,130 +33,11 @@ If you ask yourself how to compile libssh, please read INSTALL before anything.
3333

3434
http://www.libssh.org
3535

36-
4* API Changes !
36+
4* Contributing
3737
-_-_-_-_-_-_-_-_-_
3838

39-
Changes between 0.4 and 0.5
40-
---------------------------
41-
42-
We use the ssh_ prefix as namespace for every function now. There is a legacy.h
43-
which could be used to get the old function names.
44-
45-
Changes between 0.3 and 0.4
46-
---------------------------
47-
48-
We changed libssh to be typesafe now:
49-
50-
SSH_SESSION *session -> ssh_session session
51-
SFTP_SESSION *sftp -> sftp_session sftp
52-
CHANNEL *channel -> ssh_channel channel
53-
STRING *string -> ssh_string string
54-
...
55-
56-
The options structure has been removed and there is a new function. This
57-
function can set all available options now. You can find the enum in the
58-
header file and it is documented. Example:
59-
60-
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
61-
62-
5* Copyright policy
63-
-_-_-_-_-_-_-_-_-_-_
64-
65-
libssh is a project with distributed copyright ownership, which means we prefer
66-
the copyright on parts of libssh to be held by individuals rather than
67-
corporations if possible. There are historical legal reasons for this, but one
68-
of the best ways to explain it is that it’s much easier to work with
69-
individuals who have ownership than corporate legal departments if we ever need
70-
to make reasonable compromises with people using and working with libssh.
71-
72-
We track the ownership of every part of libssh via git, our source code control
73-
system, so we know the provenance of every piece of code that is committed to
74-
libssh.
75-
76-
So if possible, if you’re doing libssh changes on behalf of a company who
77-
normally owns all the work you do please get them to assign personal copyright
78-
ownership of your changes to you as an individual, that makes things very easy
79-
for us to work with and avoids bringing corporate legal departments into the
80-
picture.
81-
82-
If you can’t do this we can still accept patches from you owned by your
83-
employer under a standard employment contract with corporate copyright
84-
ownership. It just requires a simple set-up process first.
85-
86-
We use a process very similar to the way things are done in the Linux Kernel
87-
community, so it should be very easy to get a sign off from your corporate
88-
legal department. The only changes we’ve made are to accommodate the license we
89-
use, which is LGPLv2 (or later) whereas the Linux kernel uses GPLv2.
90-
91-
The process is called signing.
92-
93-
How to sign your work
94-
----------------------
95-
96-
Once you have permission to contribute to libssh from your employer, simply
97-
email a copy of the following text from your corporate email address to:
98-
99-
contributing@libssh.org
100-
101-
--------------------------------------------------------------------------
102-
libssh Developer's Certificate of Origin. Version 1.0
103-
104-
By making a contribution to this project, I certify that:
105-
106-
(a) The contribution was created in whole or in part by me and I
107-
have the right to submit it under the appropriate
108-
version of the GNU General Public License; or
109-
110-
(b) The contribution is based upon previous work that, to the best of
111-
my knowledge, is covered under an appropriate open source license
112-
and I have the right under that license to submit that work with
113-
modifications, whether created in whole or in part by me, under
114-
the GNU General Public License, in the appropriate version; or
115-
116-
(c) The contribution was provided directly to me by some other
117-
person who certified (a) or (b) and I have not modified it.
118-
119-
(d) I understand and agree that this project and the contribution are
120-
public and that a record of the contribution (including all
121-
metadata and personal information I submit with it, including my
122-
sign-off) is maintained indefinitely and may be redistributed
123-
consistent with the libssh Team's policies and the requirements of
124-
the GNU GPL where they are relevant.
125-
126-
(e) I am granting this work to this project under the terms of the
127-
GNU Lesser General Public License as published by the
128-
Free Software Foundation; either version 2.1 of
129-
the License, or (at the option of the project) any later version.
130-
131-
http://www.gnu.org/licenses/lgpl-2.1.html
132-
--------------------------------------------------------------------------
133-
134-
We will maintain a copy of that email as a record that you have the rights to
135-
contribute code to libssh under the required licenses whilst working for the
136-
company where the email came from.
137-
138-
Then when sending in a patch via the normal mechanisms described above, add a
139-
line that states:
140-
141-
142-
Signed-off-by: Random J Developer <random@developer.example.org>
143-
144-
145-
using your real name and the email address you sent the original email you used
146-
to send the libssh Developer’s Certificate of Origin to us (sorry, no
147-
pseudonyms or anonymous contributions.)
148-
149-
That’s it! Such code can then quite happily contain changes that have copyright
150-
messages such as:
151-
152-
153-
(c) Example Corporation.
154-
155-
156-
and can be merged into the libssh codebase in the same way as patches from any
157-
other individual. You don’t need to send in a copy of the libssh Developer’s
158-
Certificate of Origin for each patch, or inside each patch. Just the sign-off
159-
message is all that is required once we’ve received the initial email.
39+
Please read the file 'SubmittingPatches' next to this README file. It explains
40+
our copyright policy and how you should send patches for upstream inclusion.
16041

16142
Have fun and happy libssh hacking!
16243

include/libssh/libssh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
/* libssh version */
8080
#define LIBSSH_VERSION_MAJOR 0
8181
#define LIBSSH_VERSION_MINOR 7
82-
#define LIBSSH_VERSION_MICRO 3
82+
#define LIBSSH_VERSION_MICRO 4
8383

8484
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
8585
LIBSSH_VERSION_MINOR, \

include/libssh/misc.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2);
3333
int ssh_is_ipaddr_v4(const char *str);
3434
int ssh_is_ipaddr(const char *str);
3535

36-
#ifndef HAVE_NTOHLL
37-
/* macro for byte ordering */
38-
uint64_t ntohll(uint64_t);
39-
#endif
40-
41-
#ifndef HAVE_HTONLL
42-
#define htonll(x) ntohll((x))
43-
#endif
44-
4536
/* list processing */
4637

4738
struct ssh_list {

include/libssh/priv.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ int gettimeofday(struct timeval *__p, void *__t);
146146
#define ERROR_BUFFERLEN 1024
147147
#endif
148148
#ifndef CLIENTBANNER1
149-
#define CLIENTBANNER1 "SSH-1.5-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
149+
#define CLIENTBANNER1 "SSH-1.5-libssh_" SSH_STRINGIFY(LIBSSH_VERSION)
150150
#endif
151151
#ifndef CLIENTBANNER2
152-
#define CLIENTBANNER2 "SSH-2.0-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
152+
#define CLIENTBANNER2 "SSH-2.0-libssh_" SSH_STRINGIFY(LIBSSH_VERSION)
153153
#endif
154154
#ifndef KBDINT_MAX_PROMPT
155155
#define KBDINT_MAX_PROMPT 256 /* more than openssh's :) */
@@ -361,5 +361,25 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
361361

362362
#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
363363

364+
#ifndef HAVE_HTONLL
365+
# ifdef WORDS_BIGENDIAN
366+
# define htonll(x) (x)
367+
# else
368+
# define htonll(x) \
369+
(((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
370+
# endif
371+
#endif
372+
373+
#ifndef HAVE_NTOHLL
374+
# ifdef WORDS_BIGENDIAN
375+
# define ntohll(x) (x)
376+
# else
377+
# define ntohll(x) \
378+
(((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
379+
# endif
380+
#endif
381+
382+
void ssh_agent_state_free(void *data);
383+
364384
#endif /* _LIBSSH_PRIV_H */
365385
/* vim: set ts=4 sw=4 et cindent: */

src/auth.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@ struct ssh_agent_state_struct {
740740
char *comment;
741741
};
742742

743+
/* Internal function */
744+
void ssh_agent_state_free(void *data) {
745+
struct ssh_agent_state_struct *state = data;
746+
if (state) {
747+
ssh_string_free_char(state->comment);
748+
ssh_key_free(state->pubkey);
749+
free (state);
750+
}
751+
}
743752

744753
/**
745754
* @brief Try to do public key authentication with ssh agent.
@@ -800,9 +809,8 @@ int ssh_userauth_agent(ssh_session session,
800809
state->state == SSH_AGENT_STATE_PUBKEY){
801810
rc = ssh_userauth_try_publickey(session, username, state->pubkey);
802811
if (rc == SSH_AUTH_ERROR) {
803-
ssh_string_free_char(state->comment);
804-
ssh_key_free(state->pubkey);
805-
SAFE_FREE(session->agent_state);
812+
ssh_agent_state_free (state);
813+
session->agent_state = NULL;
806814
return rc;
807815
} else if (rc == SSH_AUTH_AGAIN) {
808816
state->state = SSH_AGENT_STATE_PUBKEY;
@@ -811,6 +819,7 @@ int ssh_userauth_agent(ssh_session session,
811819
SSH_LOG(SSH_LOG_DEBUG,
812820
"Public key of %s refused by server", state->comment);
813821
ssh_string_free_char(state->comment);
822+
state->comment = NULL;
814823
ssh_key_free(state->pubkey);
815824
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
816825
state->state = SSH_AGENT_STATE_NONE;
@@ -826,23 +835,27 @@ int ssh_userauth_agent(ssh_session session,
826835
if (rc == SSH_AUTH_AGAIN)
827836
return rc;
828837
ssh_string_free_char(state->comment);
829-
ssh_key_free(state->pubkey);
838+
state->comment = NULL;
830839
if (rc == SSH_AUTH_ERROR) {
831-
SAFE_FREE(session->agent_state);
840+
ssh_agent_state_free (session->agent_state);
841+
session->agent_state = NULL;
832842
return rc;
833843
} else if (rc != SSH_AUTH_SUCCESS) {
834844
SSH_LOG(SSH_LOG_INFO,
835845
"Server accepted public key but refused the signature");
846+
ssh_key_free(state->pubkey);
836847
state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
837848
state->state = SSH_AGENT_STATE_NONE;
838849
continue;
839850
}
840-
SAFE_FREE(session->agent_state);
851+
ssh_agent_state_free (session->agent_state);
852+
session->agent_state = NULL;
841853
return SSH_AUTH_SUCCESS;
842854
}
843855
}
844856

845-
SAFE_FREE(session->agent_state);
857+
ssh_agent_state_free (session->agent_state);
858+
session->agent_state = NULL;
846859
return rc;
847860
}
848861
#endif

src/auth1.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "config.h"
2525

26+
#include <errno.h>
2627
#include <string.h>
2728
#include <stdlib.h>
2829

@@ -117,6 +118,7 @@ static int send_username(ssh_session session, const char *username) {
117118
if (packet_send(session) == SSH_ERROR) {
118119
return SSH_AUTH_ERROR;
119120
}
121+
return SSH_AUTH_AGAIN;
120122
pending:
121123
rc = wait_auth1_status(session);
122124
switch (rc){
@@ -161,12 +163,14 @@ int ssh_userauth1_password(ssh_session session, const char *username,
161163
ssh_string pwd = NULL;
162164
int rc;
163165

166+
if (session->pending_call_state == SSH_PENDING_CALL_AUTH_PASSWORD) {
167+
goto pending;
168+
}
169+
164170
rc = send_username(session, username);
165171
if (rc != SSH_AUTH_DENIED) {
166172
return rc;
167173
}
168-
if (session->pending_call_state == SSH_PENDING_CALL_AUTH_PASSWORD)
169-
goto pending;
170174
/* we trick a bit here. A known flaw in SSH1 protocol is that it's
171175
* easy to guess password sizes.
172176
* not that sure ...
@@ -219,8 +223,11 @@ int ssh_userauth1_password(ssh_session session, const char *username,
219223
}
220224
pending:
221225
rc = wait_auth1_status(session);
222-
if (rc != SSH_AUTH_AGAIN)
223-
session->pending_call_state = SSH_PENDING_CALL_NONE;
226+
if (rc == SSH_AUTH_ERROR && errno == EAGAIN) {
227+
/* Nothing to do */
228+
} else if (rc != SSH_AUTH_AGAIN) {
229+
session->pending_call_state = SSH_PENDING_CALL_NONE;
230+
}
224231

225232
return rc;
226233
}

0 commit comments

Comments
 (0)