From ac5fb6be210b63fd7216541679f513dc97491ede Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 31 Jul 2009 17:53:02 +0000 Subject: Wow, Bu::Base64 had a bug about premature end of stream / not base64 data, now it throws exceptions. It'll still try to process bad data for a while though. Also, it turns out that Bu::File never reported EOS, now it does, appropriately. I'm about to change Bu::Stream::isEOS to be Bu::Stream::isEos, this is your warning. --- src/base64.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/base64.cpp') diff --git a/src/base64.cpp b/src/base64.cpp index c9a6b59..be5fe8d 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -1,5 +1,7 @@ #include "bu/base64.h" +namespace Bu { subExceptionDef( Base64Exception ) } + const char Bu::Base64::tblEnc[65] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" }; @@ -106,7 +108,15 @@ size_t Bu::Base64::read( void *pBuf, size_t nBytes ) for( int j = 0; j < 4; j++ ) { if( rNext.read( &buf[j], 1 ) == 0 ) + { + if( rNext.isEOS() ) + { + iChars = 0; + bEosIn = true; + throw Base64Exception("Premature end of stream detected while decoding Base64 data."); + } return sIn; + } if( buf[j] == ' ' || buf[j] == '\t' || buf[j] == '\n' || buf[j] == '\r' ) { -- cgit v1.2.3