[FFmpeg-devel] [PATCH] lavu/base64: add AV_BASE64_DECODE_SIZE() macro

Michael Niedermayer michael at niedermayer.cc
Tue Mar 29 23:43:14 CEST 2016


On Tue, Mar 29, 2016 at 12:39:23PM +0200, Stefano Sabatini wrote:
> This is consistent with the AV_BASE64_SIZE macro and avoids the literal
> use of constants in the code.
> 
> TODO: update APIchanges and bump minor.
> ---
>  libavutil/base64.h | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/base64.h b/libavutil/base64.h
> index 514498e..e8a6e41 100644
> --- a/libavutil/base64.h
> +++ b/libavutil/base64.h
> @@ -29,20 +29,25 @@
>   * @{
>   */
>  
> -
>  /**
>   * Decode a base64-encoded string.
>   *
>   * @param out      buffer for decoded data
>   * @param in       null-terminated input string
>   * @param out_size size in bytes of the out buffer, must be at
> - *                 least 3/4 of the length of in
> + *                 least 3/4 of the length of in, that is AV_BASE64_DECODE_SIZE(strlen(in))
>   * @return         number of bytes written, or a negative value in case of
>   *                 invalid input
>   */
>  int av_base64_decode(uint8_t *out, const char *in, int out_size);
>  
>  /**
> + * Calculate the output size in bytes needed to decode a base64 string
> + * with lenght x to a data buffer.
> + */
> +#define AV_BASE64_DECODE_SIZE(x) ((x) * 3 / 4)

3LL otherwise it could overflow

LGTM

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160329/aa71bb1f/attachment.sig>


More information about the ffmpeg-devel mailing list