From 777c5339a04281fc0622c3163d1b105fa7c1549b Mon Sep 17 00:00:00 2001 From: philsmd Date: Tue, 8 Sep 2020 10:48:31 +0200 Subject: [PATCH] UnRAR: Eliminate static var to make code thread-safe --- deps/unrar/rijndael.cpp | 9 +++++---- deps/unrar/rijndael.hpp | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deps/unrar/rijndael.cpp b/deps/unrar/rijndael.cpp index dd19750a3..89f287f0c 100644 --- a/deps/unrar/rijndael.cpp +++ b/deps/unrar/rijndael.cpp @@ -11,10 +11,11 @@ #include #endif -static byte S[256],S5[256],rcon[30]; -static byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; -static byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; -static byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; +// not thread-safe ? +//static byte S[256],S5[256],rcon[30]; +//static byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; +//static byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; +//static byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; inline void Xor128(void *dest,const void *arg1,const void *arg2) diff --git a/deps/unrar/rijndael.hpp b/deps/unrar/rijndael.hpp index 2144e02e5..33537d890 100644 --- a/deps/unrar/rijndael.hpp +++ b/deps/unrar/rijndael.hpp @@ -33,6 +33,11 @@ class Rijndael int m_uRounds; byte m_initVector[MAX_IV_SIZE]; byte m_expandedKey[_MAX_ROUNDS+1][4][4]; + + byte S[256],S5[256],rcon[30]; + byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; + byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; + byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; public: Rijndael(); void Init(bool Encrypt,const byte *key,uint keyLen,const byte *initVector);