diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-16 16:24:12 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-16 16:24:56 +0000 |
commit | 7de17d91bb025783c4d6e516f2d59a27e9f514ea (patch) | |
tree | 233af237047f06ee784c3ad2687a0599f4f81f6a /src/libcryptobox/base64/ref.c | |
parent | c87ebe17c3b424ecb60bb8a30de48a5a98d19ab0 (diff) | |
download | rspamd-7de17d91bb025783c4d6e516f2d59a27e9f514ea.tar.gz rspamd-7de17d91bb025783c4d6e516f2d59a27e9f514ea.zip |
[CritFix] Fix base64 decoding when there are unparseable characters
Diffstat (limited to 'src/libcryptobox/base64/ref.c')
-rw-r--r-- | src/libcryptobox/base64/ref.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libcryptobox/base64/ref.c b/src/libcryptobox/base64/ref.c index 13e3b1040..2d757fe23 100644 --- a/src/libcryptobox/base64/ref.c +++ b/src/libcryptobox/base64/ref.c @@ -174,6 +174,9 @@ repeat: break; } } + else { + leftover --; + } /* If we get here, there was an error: */ break; } @@ -188,12 +191,18 @@ repeat: break; } if ((q = base64_table_dec[*c++]) >= 254) { - leftover = 0; /* * When q == 254, the input char is '='. Return 1 and EOF. * When q == 255, the input char is invalid. Return 0 and EOF. */ - ret = ((q == 254) && (inlen == 0)) ? 1 : 0; + if (q == 254 && inlen == 0) { + ret = 1; + leftover = 0; + } + else { + ret = 0; + } + break; } |