aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2007-03-15 00:04:41 +0000
committerDan Fandrich <dan@coneharvesters.com>2007-03-15 00:04:41 +0000
commit8605321d06bb3b3da441c698c9089c5f874b5776 (patch)
treeabad0faa4913642129634c01e47d9d90f1d7e10d
parentd31445303711155262c733b4eb34c1d6461a0f41 (diff)
Fixed a memory leak.
-rw-r--r--lib/ssh.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 8cc5d63c0..2876a30c0 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -352,6 +352,12 @@ CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done)
*/
authlist = libssh2_userauth_list(ssh->ssh_session, ssh->user,
strlen(ssh->user));
+ if (!authlist) {
+ libssh2_session_free(ssh->ssh_session);
+ ssh->ssh_session = NULL;
+ Curl_safefree(ssh->path);
+ return CURLE_OUT_OF_MEMORY;
+ }
infof(data, "SSH authentication methods available: %s\n", authlist);
/*
@@ -410,6 +416,8 @@ CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done)
infof(conn->data, "Initialized keyboard interactive authentication\n");
}
}
+ Curl_safefree((void *)authlist);
+ authlist = NULL;
if (!authed) {
failf(data, "Authentication failure\n");
@@ -460,7 +468,7 @@ CURLcode Curl_ssh_connect(struct connectdata *conn, bool *done)
}
}
- /* Check for /~/ , indicating realative to the users home directory */
+ /* Check for /~/ , indicating relative to the user's home directory */
if (conn->protocol == PROT_SCP) {
real_path = (char *)malloc(working_path_len+1);
if (real_path == NULL) {
@@ -546,7 +554,7 @@ CURLcode Curl_scp_do(struct connectdata *conn, bool *done)
}
else {
/*
- * We must check the remote file, if it is a directory no vaules will
+ * We must check the remote file; if it is a directory no values will
* be set in sb
*/
curl_off_t bytecount;
@@ -782,7 +790,7 @@ CURLcode Curl_sftp_do(struct connectdata *conn, bool *done)
attrs.filesize);
}
if (attrs.flags & LIBSSH2_SFTP_ATTR_ACMODTIME) {
- const char *months[12] = {
+ static const char * const months[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
struct tm *nowParts;