aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/priv.h2
-rw-r--r--libssh/client.c5
-rw-r--r--libssh/server.c4
-rw-r--r--libssh/socket.c8
4 files changed, 13 insertions, 6 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 68fe69b5..247c4017 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -474,7 +474,7 @@ STRING *agent_sign_data(struct ssh_session *session,
/* socket.c */
struct socket;
-void ssh_socket_init(void);
+int ssh_socket_init(void);
struct socket *ssh_socket_new(SSH_SESSION *session);
void ssh_socket_free(struct socket *s);
void ssh_socket_set_fd(struct socket *s, socket_t fd);
diff --git a/libssh/client.c b/libssh/client.c
index 15e67da9..cfcaf96c 100644
--- a/libssh/client.c
+++ b/libssh/client.c
@@ -453,7 +453,10 @@ int ssh_connect(SSH_SESSION *session) {
leave_function();
return SSH_ERROR;
}
- ssh_socket_init();
+ if (ssh_socket_init() < 0) {
+ leave_function();
+ return SSH_ERROR;
+ }
if (options->fd == -1 && options->host == NULL) {
ssh_set_error(session, SSH_FATAL, "Hostname required");
diff --git a/libssh/server.c b/libssh/server.c
index 358b13e7..a3ead63b 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -105,7 +105,9 @@ int ssh_bind_listen(SSH_BIND *ssh_bind){
int fd;
if(!ssh_bind->options)
return -1;
- ssh_socket_init();
+ if (ssh_socket_init() < 0) {
+ return -1;
+ }
host=ssh_bind->options->bindaddr;
if(!host)
host="0.0.0.0";
diff --git a/libssh/socket.c b/libssh/socket.c
index d8da5771..db931454 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -75,14 +75,16 @@ struct socket {
* \internal
* \brief inits the socket system (windows specific)
*/
-void ssh_socket_init(void) {
+int ssh_socket_init(void) {
#ifdef _WIN32
struct WSAData wsaData;
- if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
- /* FIXME print error */
+ /* Initiates use of the Winsock DLL by a process. */
+ if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
+ return -1;
}
#endif
+ return 0;
}
/*
* \internal