diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2007-03-19 00:48:47 +0000 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2007-03-19 00:48:47 +0000 |
commit | bd03c380ce67cffaaf3c456407cc98e02917ebf7 (patch) | |
tree | beccff1ab797befddbd59f9e744d57d847a443e1 /libavutil/base64.c | |
parent | 559fd1e79524ca47efde195e28feb4499dd48761 (diff) | |
download | ffmpeg-bd03c380ce67cffaaf3c456407cc98e02917ebf7.tar.gz |
expose av_base64_decode and av_base64_encode
Originally committed as revision 8448 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/base64.c')
-rw-r--r-- | libavutil/base64.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libavutil/base64.c b/libavutil/base64.c index 6279244d3b..bee800c824 100644 --- a/libavutil/base64.c +++ b/libavutil/base64.c @@ -70,7 +70,7 @@ int av_base64_decode(uint8_t * out, const char *in, int out_length) * fixed edge cases and made it work from data (vs. strings) by ryan. *****************************************************************************/ -char *av_base64_encode(uint8_t * src, int len) +char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len) { static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -79,11 +79,10 @@ char *av_base64_encode(uint8_t * src, int len) int i_shift = 0; int bytes_remaining = len; - if (len < UINT_MAX / 4) { - ret = dst = av_malloc(len * 4 / 3 + 12); - } else + if (len >= UINT_MAX / 4 || + buf_len < len * 4 / 3 + 12) return NULL; - + ret = dst = buf; if (len) { // special edge case, what should we really do here? while (bytes_remaining) { i_bits = (i_bits << 8) + *src++; |