[Tarantool-patches] [PATCH v7] base64: fix decoder output buffer overrun (reads)

Sergey Nikiforov void at tarantool.org
Tue Mar 9 13:09:05 MSK 2021

On 03.03.2021 2:08, Alexander Turenko wrote:
>> -static int
>> -base64_decode_block(const char *in_base64, int in_len,
>> -		    char *out_bin, int out_len,
>> -		    struct base64_decodestate *state)
>> +int
>> +base64_decode(const char *in_base64, int in_len,
>> +	      char *out_bin, int out_len)
>>   {
>>   	const char *in_pos = in_base64;
>>   	const char *in_end = in_base64 + in_len;
>>   	char *out_pos = out_bin;
>>   	char *out_end = out_bin + out_len;
>>   	int fragment;
>> +	char curr_byte;
> AFAIR, nothing prevent us from using `*out_pos`. I don't see a reason to
> introduce `curr_byte`. It was necessary in v6 to store the initial
> state for a block.

I have removed this local var in v8.

Initially I planned to send patch series with this local var added in 
second patch and performance-optimized (w/o unnecessarily checks) 
version of decode function in third but my benchmarks have shown 
controversial effects. Adding this local var "by itself" actually 
decreases performance on one of my test machines but improves on another 
one. Optimized decode function, however, benefits from this local var 
but not when output buffer is large enough. And effect is different on 
another machine...

I haved saved optimized code (nothing really new here) and benchmark 
locally to work on them further later on.

More information about the Tarantool-patches mailing list