aboutsummaryrefslogtreecommitdiff
path: root/libssh/crypt.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-01 10:23:52 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-01 10:23:52 +0000
commit10afd9818cdf1fda8b19bae69dd2c8973dbbf606 (patch)
tree4696d78283035be142da90263ffd43a899f49970 /libssh/crypt.c
parent186667724a70dc146ac92e03ab4eb3eb2cee222d (diff)
downloadlibssh-10afd9818cdf1fda8b19bae69dd2c8973dbbf606.tar.gz
libssh-10afd9818cdf1fda8b19bae69dd2c8973dbbf606.tar.xz
libssh-10afd9818cdf1fda8b19bae69dd2c8973dbbf606.zip
Check for memory allocation errors.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@316 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/crypt.c')
-rw-r--r--libssh/crypt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libssh/crypt.c b/libssh/crypt.c
index 49aa44b..75c22df 100644
--- a/libssh/crypt.c
+++ b/libssh/crypt.c
@@ -39,8 +39,12 @@
u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
u32 decrypted;
- if(session->current_crypto)
- packet_decrypt(session,crypted,session->current_crypto->in_cipher->blocksize);
+ if (session->current_crypto) {
+ if (packet_decrypt(session, crypted,
+ session->current_crypto->in_cipher->blocksize) < 0) {
+ return ntohl(0);
+ }
+ }
memcpy(&decrypted,crypted,sizeof(decrypted));
ssh_log(session, SSH_LOG_PACKET,
"Packet size decrypted: %lu (0x%lx)",
@@ -52,6 +56,9 @@ u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
int packet_decrypt(SSH_SESSION *session, void *data,u32 len){
struct crypto_struct *crypto=session->current_crypto->in_cipher;
char *out=malloc(len);
+ if (out == NULL) {
+ return -1;
+ }
ssh_log(session,SSH_LOG_PACKET,"Decrypting %d bytes",len);
#ifdef HAVE_LIBGCRYPT
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey,session->current_crypto->decryptIV);