[Tarantool-patches] [PATCH v2] base64: Properly ignore invalid characters

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Dec 17 02:28:11 MSK 2020


Thanks for the patch!

> diff --git a/test/unit/base64.c b/test/unit/base64.c
> index ada497adf..c0f53a5e1 100644
> --- a/test/unit/base64.c
> +++ b/test/unit/base64.c
> @@ -58,9 +58,28 @@ base64_nowrap_test(const char *str)
>  	base64_test(str, BASE64_NOWRAP, symbols, lengthof(symbols));
>  }
>  
> +static void
> +base64_invalid_chars_test(void)
> +{
> +	/* Upper bit must be cleared */
> +	const char invalid_data[] = { '\x7b', '\x7c', '\x7d', '\x7e' };
> +	char outbuf[8];
> +
> +	plan(1);
> +
> +	/* Invalid chars should be ignored, not decoded into garbage */
> +	is(base64_decode(invalid_data, sizeof(invalid_data),
> +	                 outbuf, sizeof(outbuf)),
> +	   0, "ignoring invalid chars");
> +
> +	check_plan();
> +}
> +
>  int main(int argc, char *argv[])
>  {
> -	plan(28);
> +	plan(28
> +	     + 1 /* invalid chars test */
> +	     );

Why not just 29? It looks kind of weird now.

The patch looks good. Get a second review from somebody, and I
will commit this.


More information about the Tarantool-patches mailing list