aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/base64.c
diff options
context:
space:
mode:
authorlarrybr <larrybr@noemail.net>2022-11-22 19:04:09 +0000
committerlarrybr <larrybr@noemail.net>2022-11-22 19:04:09 +0000
commitbf82c95e08e9c0e442ded343ee8644778f873eef (patch)
treebcaba178dee84f15293ded291bef21cc63c23d72 /ext/misc/base64.c
parentb5aaf0f28507a27a2ea8e18f642625d8727e9c48 (diff)
parent2a072506ca4ca14839f88ca1c027436e9d68c7c4 (diff)
downloadsqlite-bf82c95e08e9c0e442ded343ee8644778f873eef.tar.gz
sqlite-bf82c95e08e9c0e442ded343ee8644778f873eef.zip
Add test/basexx1.test to test is_base85(t), base85(x) and base64(x). Sync w/trunk.
FossilOrigin-Name: 4e4334547795f659b4a5dc5fdaf842535643750a5f1ce1af799c526931a473e4
Diffstat (limited to 'ext/misc/base64.c')
-rw-r--r--ext/misc/base64.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/misc/base64.c b/ext/misc/base64.c
index 1ab0dc4ea..dfeadcb16 100644
--- a/ext/misc/base64.c
+++ b/ext/misc/base64.c
@@ -22,7 +22,8 @@
**
** The conversions meet RFC 4648 requirements, provided that this
** C source specifies that line-feeds are included in the encoded
-** data to limit visible line lengths to 72 characters.
+** data to limit visible line lengths to 72 characters and to
+** terminate any encoded blob having non-zero length.
**
** Length limitations are not imposed except that the runtime
** SQLite string or blob length limits are respected. Otherwise,
@@ -148,17 +149,20 @@ static ubyte* fromBase64( char *pIn, int ncIn, ubyte *pOut ){
ncIn -= (pUse - pIn);
pIn = pUse;
nti = (ncIn>4)? 4 : ncIn;
+ ncIn -= nti;
nbo = nboi[nti];
if( nbo==0 ) break;
for( nac=0; nac<4; ++nac ){
- char c = (nac<=nti)? *pIn++ : PAD_CHAR;
+ char c = (nac<nti)? *pIn++ : b64Numerals[0];
ubyte bdp = BX_DV_PROTO(c);
- --ncIn;
switch( bdp ){
- case WS:
case ND:
- nti = 0;
- break;
+ /* Treat non-digits as pad, but they terminate decode too. */
+ ncIn = 0;
+ /* fall thru */
+ case WS:
+ /* Treat whitespace as pad */
+ /* fall thru */
case PC:
bdp = 0;
--nbo;