From 06ec3d50d0f58b15199a7230f82769ca3a702154 Mon Sep 17 00:00:00 2001
From: Alexander Turenko <alexander.turenko@tarantool.org>
Date: Mon, 14 May 2018 09:50:08 +0300
Subject: [PATCH] Use automatic storage for digest.pbkdf2 results

It prevents rewriting result by an another thread after coio_call(), but
before lua_pushlstring(). Such case is possible because libeio uses
thread pool internally and static __thread storage can be reused before
lua_pushlstring() if many parallel digest.pbkdf2() calls are on the fly.

Fixes #3396.
---
 src/lua/digest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lua/digest.c b/src/lua/digest.c
index bf738b3f5a..b0572baf75 100644
--- a/src/lua/digest.c
+++ b/src/lua/digest.c
@@ -79,7 +79,7 @@ lua_pbkdf2(lua_State *L)
 	const char *salt = lua_tostring(L, 2);
 	int num_iterations = lua_tointeger(L, 3);
 	int digest_len = lua_tointeger(L, 4);
-	static __thread unsigned char digest[PBKDF2_MAX_DIGEST_SIZE];
+	unsigned char digest[PBKDF2_MAX_DIGEST_SIZE];
 
 	if (coio_call(digest_pbkdf2_f, password, strlen(password), salt,
 				  strlen(salt), digest, num_iterations, digest_len) < 0) {
@@ -99,4 +99,4 @@ tarantool_lua_digest_init(struct lua_State *L)
 	};
 	luaL_register_module(L, "digest", lua_digest_methods);
 	lua_pop(L, 1);
-};
\ No newline at end of file
+};
-- 
GitLab