diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-01 21:24:16 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-01 21:24:16 +0000 |
commit | 891539af6cbdbdfabb8d37fb491f7f8cadf9823c (patch) | |
tree | 1699cb47cd68dc35a972f8b5e1d834946c48d944 /libssh/keyfiles.c | |
parent | 1b627b386763e22a7b8f7a7c8de9610c1da56cd2 (diff) | |
download | libssh-891539af6cbdbdfabb8d37fb491f7f8cadf9823c.tar.gz libssh-891539af6cbdbdfabb8d37fb491f7f8cadf9823c.tar.xz libssh-891539af6cbdbdfabb8d37fb491f7f8cadf9823c.zip |
Add memory error checks for crypto wrapper functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@330 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r-- | libssh/keyfiles.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index cefcc98..d91d035 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -993,10 +993,14 @@ static int match_hashed_host(SSH_SESSION *session, char *host, char *sourcehash) if(strncmp(sourcehash,"|1|",3) != 0) return 0; source=strdup(sourcehash+3); + if (source == NULL) { + leave_function(); + return 0; + } b64hash=strchr(source,'|'); if(!b64hash){ /* Invalid hash */ - free(source); + SAFE_FREE(source); leave_function(); return 0; } @@ -1006,6 +1010,11 @@ static int match_hashed_host(SSH_SESSION *session, char *host, char *sourcehash) hash=base64_to_bin(b64hash); free(source); mac=hmac_init(buffer_get(salt),buffer_get_len(salt),HMAC_SHA1); + if (mac == NULL) { + SAFE_FREE(source); + leave_function(); + return 0; + } hmac_update(mac,host,strlen(host)); hmac_final(mac,buffer,&size); if(size == buffer_get_len(hash) && memcmp(buffer,buffer_get(hash),size)==0) |