summaryrefslogtreecommitdiff
path: root/src/base64.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-07-31 17:53:02 +0000
committerMike Buland <eichlan@xagasoft.com>2009-07-31 17:53:02 +0000
commitac5fb6be210b63fd7216541679f513dc97491ede (patch)
treeacbc8a91933f9e200d51f9a58f4f7b05173611ab /src/base64.cpp
parent6070f3cb3fe44f17114fd58792055e9c91bd3576 (diff)
downloadlibbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.gz
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.bz2
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.tar.xz
libbu++-ac5fb6be210b63fd7216541679f513dc97491ede.zip
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.
Diffstat (limited to 'src/base64.cpp')
-rw-r--r--src/base64.cpp10
1 files changed, 10 insertions, 0 deletions
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 @@
1#include "bu/base64.h" 1#include "bu/base64.h"
2 2
3namespace Bu { subExceptionDef( Base64Exception ) }
4
3const char Bu::Base64::tblEnc[65] = { 5const char Bu::Base64::tblEnc[65] = {
4 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 6 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
5}; 7};
@@ -106,7 +108,15 @@ size_t Bu::Base64::read( void *pBuf, size_t nBytes )
106 for( int j = 0; j < 4; j++ ) 108 for( int j = 0; j < 4; j++ )
107 { 109 {
108 if( rNext.read( &buf[j], 1 ) == 0 ) 110 if( rNext.read( &buf[j], 1 ) == 0 )
111 {
112 if( rNext.isEOS() )
113 {
114 iChars = 0;
115 bEosIn = true;
116 throw Base64Exception("Premature end of stream detected while decoding Base64 data.");
117 }
109 return sIn; 118 return sIn;
119 }
110 if( buf[j] == ' ' || buf[j] == '\t' || 120 if( buf[j] == ' ' || buf[j] == '\t' ||
111 buf[j] == '\n' || buf[j] == '\r' ) 121 buf[j] == '\n' || buf[j] == '\r' )
112 { 122 {