[FFmpeg-devel] [PATCH] remove unused and broken test program in libavutil/base64.c

Stefano Sabatini stefano.sabatini-lala
Sat Jan 31 00:26:20 CET 2009


On date Friday 2009-01-30 17:06:22 +0100, Michael Niedermayer encoded:
> On Fri, Jan 30, 2009 at 12:46:36AM +0100, Stefano Sabatini wrote:
[...]
> > I think I addressed all the points.
> > 
> > Round 5:
> > ------------------8<----------------------8<-------------------------
> > #ifdef TEST
> > #include "mem.h"
> > #include "lfg.h"
> > 
> > #undef printf
> > 
> > #define MAX_DATA_SIZE    1024
> > #define MAX_ENCODED_SIZE 2048
> > 
> 
> > #define SHOW_STUFF(stuff) show_stuff ? (const char *)stuff : "[...]"
> 
> please explain wat this is supposed to be good for?

Yes, here there is the first lines of the output:

Encoding/decoding tests
Encoding data with size 0 bytes ''... encoded as ''... passed!
Encoding data with size 1 bytes '1'... encoded as 'MQ=='... passed!
Encoding data with size 2 bytes '22'... encoded as 'MjI='... passed!
Encoding data with size 3 bytes '333'... encoded as 'MzMz'... passed!
Encoding data with size 4 bytes '4444'... encoded as 'NDQ0NA=='... passed!
Encoding data with size 5 bytes '55555'... encoded as 'NTU1NTU='... passed!
Encoding data with size 6 bytes '666666'... encoded as 'NjY2NjY2'... passed!
Encoding data with size 7 bytes 'abc:def'... encoded as 'YWJjOmRlZg=='... passed!
Encoding data with size 0 bytes '[...]'... encoded as '[...]'... passed!
Encoding data with size 968 bytes '[...]'... encoded as '[...]'... passed!
Encoding data with size 780 bytes '[...]'... encoded as '[...]'... passed!
Encoding data with size 647 bytes '[...]'... encoded as '[...]'... passed!
...

For the data with a reference encoded string I think it is a good idea
to show how the data is encoded, in case of problem the hacker should
be able to immediately spot where the problem is.

For the other ones the length of the encoded string is usually too
long and it is too awkward to display it, but no strong opinion on
this, just tell how do you prefer it.
 
> [...]
> >     printf("\nDecoding tests on invalid data\n");
> >     {
> >         uint8_t data[32];
> >         const char *encoded[] = { "M", "M=M=", "MQ===" };
> 
> why is this splited off and not in the main table?

I believe this test cannot be reduced to the previous one, here we're
just *decoding* and checking for validity.
 
> > 
> >         for (int i=0; i < FF_ARRAY_ELEMS(encoded); i++) {
> >             printf("Decoding invalid encoded string '%s'... ", encoded[i]);
> >             if (av_base64_decode(data, encoded[i], sizeof(data)) >= 0) {
> >                 printf("failed: data considered valid!\n");
> >                 error_count++;
> 
> >             }
> >             else
> 
> this is not K&R style

Fixed (locally).

Regards.
-- 
FFmpeg = Fostering and Fundamental Murdering Peaceful Educated Guru




More information about the ffmpeg-devel mailing list