diff --git a/include/polarssl/base64.h b/include/polarssl/base64.h index fb0d753a2..d04149344 100644 --- a/include/polarssl/base64.h +++ b/include/polarssl/base64.h @@ -3,7 +3,7 @@ * * \brief RFC 1521 base64 encoding/decoding * - * Copyright (C) 2006-2010, Brainspark B.V. + * Copyright (C) 2006-2013, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -57,7 +57,7 @@ int base64_encode( unsigned char *dst, size_t *dlen, /** * \brief Decode a base64-formatted buffer * - * \param dst destination buffer + * \param dst destination buffer (can be NULL for checking size) * \param dlen size of the buffer * \param src source buffer * \param slen amount of data to be decoded @@ -67,8 +67,8 @@ int base64_encode( unsigned char *dst, size_t *dlen, * not correct. *dlen is always updated to reflect the amount * of data that has (or would have) been written. * - * \note Call this function with *dlen = 0 to obtain the - * required buffer size in *dlen + * \note Call this function with *dst = NULL or *dlen = 0 to obtain + * the required buffer size in *dlen */ int base64_decode( unsigned char *dst, size_t *dlen, const unsigned char *src, size_t slen ); diff --git a/library/base64.c b/library/base64.c index 06305bb5e..4b823b297 100644 --- a/library/base64.c +++ b/library/base64.c @@ -1,7 +1,7 @@ /* * RFC 1521 base64 encoding/decoding * - * Copyright (C) 2006-2010, Brainspark B.V. + * Copyright (C) 2006-2013, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -163,7 +163,7 @@ int base64_decode( unsigned char *dst, size_t *dlen, n = ((n * 6) + 7) >> 3; - if( *dlen < n ) + if( dst == NULL || *dlen < n ) { *dlen = n; return( POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL );