1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

crypto: check malloc return in ssh_mac_ctx_init

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jon Simons
2014-09-26 21:13:01 -07:00
committed by Andreas Schneider
parent 092fe0b727
commit af25c5e668
2 changed files with 10 additions and 2 deletions

View File

@@ -250,7 +250,11 @@ void md5_final(unsigned char *md, MD5CTX c) {
} }
ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type){ ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type){
ssh_mac_ctx ctx=malloc(sizeof(struct ssh_mac_ctx_struct)); ssh_mac_ctx ctx = malloc(sizeof(struct ssh_mac_ctx_struct));
if (ctx == NULL) {
return NULL;
}
ctx->mac_type=type; ctx->mac_type=type;
switch(type){ switch(type){
case SSH_MAC_SHA1: case SSH_MAC_SHA1:

View File

@@ -150,7 +150,11 @@ void md5_final(unsigned char *md, MD5CTX c) {
} }
ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type){ ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type){
ssh_mac_ctx ctx=malloc(sizeof(struct ssh_mac_ctx_struct)); ssh_mac_ctx ctx = malloc(sizeof(struct ssh_mac_ctx_struct));
if (ctx == NULL) {
return NULL;
}
ctx->mac_type=type; ctx->mac_type=type;
switch(type){ switch(type){
case SSH_MAC_SHA1: case SSH_MAC_SHA1: