From 07ae5bf9656df20774852b41381bd91616b079c5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 22 May 2008 03:42:26 +0000 Subject: [PATCH] tr_base64_decode() now decodes both data with, and without, newlines. thanks to dm1024 for helping track this down. --- libtransmission/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libtransmission/utils.c b/libtransmission/utils.c index e61edf3b8..fecd2be36 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -1078,6 +1078,17 @@ tr_base64_decode( const void * input, int length, int * setme_len ) bmem = BIO_new_mem_buf( (unsigned char*)input, length ); bmem = BIO_push( b64, bmem ); retlen = BIO_read( bmem, ret, length ); + if( !retlen ) + { + /* try again, but with the BIO_FLAGS_BASE64_NO_NL flag */ + BIO_free_all( bmem ); + b64 = BIO_new( BIO_f_base64( ) ); + BIO_set_flags( b64, BIO_FLAGS_BASE64_NO_NL ); + bmem = BIO_new_mem_buf( (unsigned char*)input, length ); + bmem = BIO_push( b64, bmem ); + retlen = BIO_read( bmem, ret, length ); + } + if( setme_len ) *setme_len = retlen; -- 2.40.0