diff options
author | Alex Dowad <alexinbeijing@gmail.com> | 2020-05-27 06:01:22 +0200 |
---|---|---|
committer | Alex Dowad <alexinbeijing@gmail.com> | 2020-06-23 16:10:54 +0200 |
commit | 7a9f0cc3d05f860268e3fd28fff17d12c5671f97 (patch) | |
tree | 042cc8880c1eb9c6e485067582859db9b8b1d217 /ext/reflection/php_reflection.c | |
parent | 9bd648ba1e54c1f3dc8de19772a4f038fe9320a7 (diff) | |
download | php-git-7a9f0cc3d05f860268e3fd28fff17d12c5671f97.tar.gz |
Simplify `_crypt_extended_init_r`, and fix redundant initialization on Win32/Solaris
Looking at the history of this function, the original implementation had a bug where
it would return from the middle of the function without unlocking the mutex first.
The author attempted to fix this by incrementing the `initialized` flag atomically,
which is not necessary, since the section which modifies the flag is protected by a
mutex.
Coincidentally, at the same time that all this unnecessary 'atomic' machinery was
introduced, the code was also changed so that it didn't return without unlocking the
mutex. So it looks like the bug was fixed by accident.
It's not necessary to declare the flag as `volatile` either, since it is protected
by a mutex.
Further, the 'fixed' implementation was also wrong in another respect: on Windows
and Solaris, the `initialized` flag was not even declared as `static`!! So the
initialization of the static tables for S-boxes, P-boxes, etc. was repeated on
each call to `php_crypt`, completely defeating the purpose of this function.
Diffstat (limited to 'ext/reflection/php_reflection.c')
0 files changed, 0 insertions, 0 deletions