[FFmpeg-devel] [RFC] AES init

Michael Niedermayer michaelni
Sun May 13 17:37:16 CEST 2007


On Sun, May 13, 2007 at 04:27:38PM +0200, Alex Beregszaszi wrote:
> Hi,
> Current AES tables init looks as follows:
> if(!enc_multbl[4][1023]){
> While the tables are defined as:
> static uint32_t enc_multbl[1][256];
> static uint32_t dec_multbl[1][256];
> #else
> static uint32_t enc_multbl[4][256];
> static uint32_t dec_multbl[4][256];
> #endif
> That means [4][1023] is pointing to an invalid area in both case.
> For my case, this caused AES to malfunction, the AES struct was not
> inited (only the key's were there). This happened to me in GCC 4.0.3.
> My change is as follows, introducing a bad static variable. Other
> solution would be checking for enc_multbl[0][0] ? But than again, this
> probably breaks with compilers not zeroing those variables (like VisualC
> which sets them to 0xCC). I know some will shout that "broken compilers
> are not supported".

global/static variables must be zeroed (see C standard)
also static type foober[123]={0} will zero it

and the inited code is not thread safe if the first thread gets
interrupted after inited=1 but before actually initalizing anything
then a second thread could pass over the init code with the init never

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070513/f84e59aa/attachment.pgp>

More information about the ffmpeg-devel mailing list