Commit 8c027351cb5a3bb16f279795f32027c92f61039a

Patrick Steinhardt 2017-05-02T13:35:09

transports: ssh: report failure initializing libssh2 We unconditionally return success when initializing libssh2, regardless of whether `libgssh2_init` signals success or an error. Fix this by checking its return code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 44d02e5..d195d58 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -896,8 +896,11 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
 int git_transport_ssh_global_init(void)
 {
 #ifdef GIT_SSH
+	if (libssh2_init(0) < 0) {
+		giterr_set(GITERR_SSH, "unable to initialize libssh2");
+		return -1;
+	}
 
-	libssh2_init(0);
 	return 0;
 
 #else