]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Fix base64 decoding when there are unparseable characters
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Mar 2017 16:24:12 +0000 (16:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Mar 2017 16:24:56 +0000 (16:24 +0000)
src/libcryptobox/base64/ref.c
src/libcryptobox/base64/sse42.c

index 13e3b1040dd06e4d44033a8a39c2a4ba5b9d3c90..2d757fe23a0b05463b4978d3557976d15595e17d 100644 (file)
@@ -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;
                        }
 
index ea5a6e1d6a2a5bb9c3d8e9ab3302438e51b2cb14..12c6e3413a3cf7d912733fa6ea2b716981bcfb8a 100644 (file)
@@ -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;
                        }