diff --git a/base64_from.c b/base64_from.c index aabd84f..808bf1d 100644 --- a/base64_from.c +++ b/base64_from.c @@ -84,6 +84,9 @@ int base64_valid(const char *src,size_t *count) for (p = src;base64f[(u8)*p] != 0xFF;++p) ; + for (;*p == '=';++p) + ; + if (count) *count = (size_t) (p - src); return !*p; diff --git a/main.c b/main.c index 80e3df3..79552a3 100644 --- a/main.c +++ b/main.c @@ -667,22 +667,6 @@ int main(int argc,char **argv) exit(Q_FAILOPENOUTPUT); // define new err code? } - filters_prepare(); - - filters_print(); - -#ifdef STATISTICS - if (!filters_count() && !reportdelay) -#else - if (!filters_count()) -#endif - return 0; - -#ifdef EXPANDMASK - if (numwords > 1 && flattened) - fprintf(stderr,"WARNING: -N switch will produce bogus results because we can't know filter width. reconfigure with --enable-besort and recompile.\n"); -#endif - if (workdir) createdir(workdir,1); @@ -720,6 +704,22 @@ int main(int argc,char **argv) goto done; } + filters_prepare(); + + filters_print(); + +#ifdef STATISTICS + if (!filters_count() && !reportdelay) +#else + if (!filters_count()) +#endif + return 0; + +#ifdef EXPANDMASK + if (numwords > 1 && flattened) + fprintf(stderr,"WARNING: -N switch will produce bogus results because we can't know filter width. reconfigure with --enable-besort and recompile.\n"); +#endif + if (yamloutput) yamlout_init(); diff --git a/test_base64.c b/test_base64.c index cebb030..bd7fbf6 100644 --- a/test_base64.c +++ b/test_base64.c @@ -32,6 +32,10 @@ int main(void) tests0[i].in, buf, tests0[i].out); return 1; } + if (!base64_valid(buf,0)) { + printf("encoded data is considered invalid\n"); + return 3; + } r = base64_from((u8 *)buf2, buf, strlen(buf)); buf2[r] = '\0'; if (strcmp(buf2, tests0[i].rev) != 0) {