aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-05-31 09:17:54 +0200
committerAndreas Schneider <asn@cynapses.org>2010-05-31 09:17:54 +0200
commit560e93803804224c137d8dee6eae99ab2296734a (patch)
treedaa9044a35ff95fda19d2c6d84925bde1cac24a1 /libssh
parent2a5d71971c9108d7b8e866c9f2364d4613bc22cb (diff)
downloadlibssh-560e93803804224c137d8dee6eae99ab2296734a.tar.gz
libssh-560e93803804224c137d8dee6eae99ab2296734a.tar.xz
libssh-560e93803804224c137d8dee6eae99ab2296734a.zip
misc: Move size check down in ssh_path_expand_escape().
Diffstat (limited to 'libssh')
-rw-r--r--libssh/misc.c11
-rw-r--r--libssh/options.c2
2 files changed, 7 insertions, 6 deletions
diff --git a/libssh/misc.c b/libssh/misc.c
index c971367..555c25b 100644
--- a/libssh/misc.c
+++ b/libssh/misc.c
@@ -597,17 +597,18 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
const char *p;
size_t i, l;
- if (strlen(s) > MAX_BUF_SIZE) {
- ssh_set_error(session, SSH_FATAL, "string to expand too long");
- return NULL;
- }
-
r = ssh_path_expand_tilde(s);
if (r == NULL) {
ssh_set_error_oom(session);
return NULL;
}
+ if (strlen(r) > MAX_BUF_SIZE) {
+ ssh_set_error(session, SSH_FATAL, "string to expand too long");
+ free(r);
+ return NULL;
+ }
+
p = r;
buf[0] = '\0';
diff --git a/libssh/options.c b/libssh/options.c
index 4fdd5dc..f87af58 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -425,7 +425,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
if (value == NULL) {
SAFE_FREE(session->sshdir);
- session->sshdir = ssh_path_expand_tilde("~/.ssh/");
+ session->sshdir = ssh_path_expand_tilde("~/.ssh");
if (session->sshdir == NULL) {
return -1;
}