Fix integer overflow in mbedtls_base64_decode()

Fix potential integer overflows in the function mbedtls_base64_decode().
This overflow would mainly be exploitable in 32-bit systems and could
cause buffer bound checks to be bypassed.
This commit is contained in:
Andres AG 2017-01-18 17:21:03 +00:00 committed by Simon Butcher
parent 74ef650772
commit 59abd301f5
2 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,8 @@ Bugfix
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
* Fixed potential arithmetic overflow in mbedtls_md2_update() that could
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
* Fixed potential arithmetic overflow in mbedtls_base64_decode() that could
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
= mbed TLS 1.3.18 branch 2016-10-17

View File

@ -198,7 +198,7 @@ int base64_decode( unsigned char *dst, size_t *dlen,
return( 0 );
}
n = ( ( n * 6 ) + 7 ) >> 3;
n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 );
n -= j;
if( dst == NULL || *dlen < n )