From a885d6835fd42882a1eff1677db77a0d7b6ddbfd Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Thu, 20 Jan 2011 16:35:05 +0000
Subject: [PATCH] - Require different input and output buffer in
cipher_update() - Fixed style typos
---
library/cipher.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/library/cipher.c b/library/cipher.c
index 345e2fee1..697ff5430 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -197,8 +197,11 @@ int cipher_update( cipher_context_t *ctx, const unsigned char *input, int ilen,
{
int copy_len = 0;
- if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen )
+ if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ||
+ input == output )
+ {
return 1;
+ }
*olen = 0;
@@ -295,16 +298,16 @@ static int get_pkcs_padding( unsigned char *input, unsigned char input_len,
int i = 0;
unsigned char padding_len = 0;
- if ( NULL == input || NULL == data_len )
+ if( NULL == input || NULL == data_len )
return 1;
padding_len = input[input_len - 1];
- if ( padding_len > input_len )
+ if( padding_len > input_len )
return 2;
- for ( i = input_len - padding_len; i < input_len; i++ )
- if ( input[i] != padding_len )
+ for( i = input_len - padding_len; i < input_len; i++ )
+ if( input[i] != padding_len )
return 2;
*data_len = input_len - padding_len;