From 279432a7c015bcb8f5b22a2aa6335c754db0f335 Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Thu, 26 Apr 2012 10:09:35 +0000
Subject: [PATCH] - Fixed size of clean
---
library/cipher.c | 2 +-
library/md.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/library/cipher.c b/library/cipher.c
index 85c74aba1..0d1258bc9 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -260,7 +260,7 @@ int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info )
if( NULL == cipher_info || NULL == ctx )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
- memset( ctx, 0, sizeof( ctx ) );
+ memset( ctx, 0, sizeof( cipher_context_t ) );
if( NULL == ( ctx->cipher_ctx = cipher_info->base->ctx_alloc_func() ) )
return POLARSSL_ERR_CIPHER_ALLOC_FAILED;
diff --git a/library/md.c b/library/md.c
index d15bf1dca..96065c95f 100644
--- a/library/md.c
+++ b/library/md.c
@@ -152,11 +152,10 @@ const md_info_t *md_info_from_type( md_type_t md_type )
int md_init_ctx( md_context_t *ctx, const md_info_t *md_info )
{
- if( md_info == NULL )
+ if( md_info == NULL || ctx == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
- if( ctx == NULL || ctx->md_ctx != NULL )
- return POLARSSL_ERR_MD_BAD_INPUT_DATA;
+ memset( ctx, 0, sizeof( md_context_t ) );
if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL )
return POLARSSL_ERR_MD_ALLOC_FAILED;