From: Vsevolod Stakhov Date: Thu, 16 Mar 2017 16:24:12 +0000 (+0000) Subject: [CritFix] Fix base64 decoding when there are unparseable characters X-Git-Tag: 1.5.3~14 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7de17d91bb025783c4d6e516f2d59a27e9f514ea;p=rspamd.git [CritFix] Fix base64 decoding when there are unparseable characters --- 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; } diff --git a/src/libcryptobox/base64/sse42.c b/src/libcryptobox/base64/sse42.c index ea5a6e1d6..12c6e3413 100644 --- a/src/libcryptobox/base64/sse42.c +++ b/src/libcryptobox/base64/sse42.c @@ -203,6 +203,9 @@ repeat: break; } } + else { + leftover --; + } /* If we get here, there was an error: */ break; } @@ -217,12 +220,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; }