+7
-7
| { | ||
| "name": "lmdb", | ||
| "author": "Kris Zyp", | ||
| "version": "3.2.1", | ||
| "version": "3.2.2", | ||
| "description": "Simple, efficient, scalable, high-performance LMDB interface", | ||
@@ -114,9 +114,9 @@ "license": "MIT", | ||
| "optionalDependencies": { | ||
| "@lmdb/lmdb-darwin-arm64": "3.2.1", | ||
| "@lmdb/lmdb-darwin-x64": "3.2.1", | ||
| "@lmdb/lmdb-linux-arm": "3.2.1", | ||
| "@lmdb/lmdb-linux-arm64": "3.2.1", | ||
| "@lmdb/lmdb-linux-x64": "3.2.1", | ||
| "@lmdb/lmdb-win32-x64": "3.2.1" | ||
| "@lmdb/lmdb-darwin-arm64": "3.2.2", | ||
| "@lmdb/lmdb-darwin-x64": "3.2.2", | ||
| "@lmdb/lmdb-linux-arm": "3.2.2", | ||
| "@lmdb/lmdb-linux-arm64": "3.2.2", | ||
| "@lmdb/lmdb-linux-x64": "3.2.2", | ||
| "@lmdb/lmdb-win32-x64": "3.2.2" | ||
| } | ||
| } |
+10
-16
@@ -404,19 +404,13 @@ import { RangeIterable } from './util/RangeIterable.js'; | ||
| }; | ||
| let userSharedBuffers = | ||
| this._userSharedBuffers || (this._userSharedBuffers = new Map()); | ||
| let sharedBuffer = userSharedBuffers.get(id.toString()); | ||
| if (!sharedBuffer) { | ||
| setKeyBytes(); | ||
| let sharedBuffer = getUserSharedBuffer( | ||
| env.address, | ||
| keySize, | ||
| defaultBuffer, | ||
| options?.callback, | ||
| ); | ||
| sharedBuffer.notify = () => { | ||
| setKeyBytes(); | ||
| sharedBuffer = getUserSharedBuffer( | ||
| env.address, | ||
| keySize, | ||
| defaultBuffer, | ||
| options?.callback, | ||
| ); | ||
| userSharedBuffers.set(id.toString(), sharedBuffer); | ||
| sharedBuffer.notify = () => { | ||
| setKeyBytes(); | ||
| return notifyUserCallbacks(env.address, keySize); | ||
| }; | ||
| } | ||
| return notifyUserCallbacks(env.address, keySize); | ||
| }; | ||
| return sharedBuffer; | ||
@@ -423,0 +417,0 @@ }, |
+26
-14
@@ -1088,2 +1088,3 @@ #include "lmdb-js.h" | ||
| } | ||
| NAPI_FUNCTION(getUserSharedBuffer) { | ||
@@ -1095,4 +1096,2 @@ ARGS(4) | ||
| GET_UINT32_ARG(size, 1); | ||
| MDB_val default_buffer; | ||
| napi_get_arraybuffer_info(env, args[2], &default_buffer.mv_data, &default_buffer.mv_size); | ||
| ExtendedEnv* extend_env = (ExtendedEnv*) mdb_env_get_userctx(ew->env); | ||
@@ -1106,19 +1105,27 @@ std::string key(ew->keyBuffer, size); | ||
| // get a shared buffer with the key, starting value, and convert pointer to an array buffer | ||
| MDB_val buffer = extend_env->getUserSharedBuffer(key, default_buffer, args[3], has_callback, env, ew); | ||
| if (buffer.mv_data == default_buffer.mv_data) return args[2]; | ||
| napi_value return_value; | ||
| napi_create_external_arraybuffer(env, buffer.mv_data, buffer.mv_size, cleanupLMDB, buffer.mv_data, &return_value); | ||
| return return_value; | ||
| napi_value buffer = extend_env->getUserSharedBuffer(key, args[2], args[3], has_callback, env, ew); | ||
| return buffer; | ||
| } | ||
| /*napi_finalize cleanup_callback = [](napi_env env, void* data, void* buffer_info) { | ||
| // Data belongs to LMDB, we shouldn't free it here | ||
| }*/ | ||
| MDB_val ExtendedEnv::getUserSharedBuffer(std::string key, MDB_val default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew) { | ||
| napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew) { | ||
| pthread_mutex_lock(&userBuffersLock); | ||
| auto resolution = userSharedBuffers.find(key); | ||
| if (resolution == userSharedBuffers.end()) { | ||
| void* default_buffer_data; | ||
| size_t default_buffer_size; | ||
| napi_get_arraybuffer_info(env, default_buffer, &default_buffer_data, &default_buffer_size); | ||
| char* buffer_data = new char[default_buffer_size]; | ||
| memcpy(buffer_data, default_buffer_data, default_buffer_size); | ||
| MDB_val buffer; | ||
| buffer.mv_data = (void*)buffer_data; | ||
| buffer.mv_size = default_buffer_size; | ||
| user_buffer_t user_shared_buffer; | ||
| user_shared_buffer.buffer = default_buffer; | ||
| user_shared_buffer.buffer = buffer; | ||
| resolution = userSharedBuffers.emplace(key, user_shared_buffer).first; | ||
| } | ||
| if (has_callback) { | ||
@@ -1136,6 +1143,11 @@ napi_threadsafe_function callback; | ||
| } | ||
| MDB_val buffer = resolution->second.buffer; | ||
| napi_value buffer_value; | ||
| napi_create_external_arraybuffer(env, resolution->second.buffer.mv_data, resolution->second.buffer.mv_size, nullptr, nullptr, &buffer_value); | ||
| pthread_mutex_unlock(&userBuffersLock); | ||
| return buffer; | ||
| return buffer_value; | ||
| } | ||
| /** | ||
@@ -1142,0 +1154,0 @@ * Notify the user callbacks associated with a user buffer for a given key |
+1
-1
@@ -301,3 +301,3 @@ #ifndef NODE_LMDB_H | ||
| uint64_t previousTime; // actually encoded as double | ||
| MDB_val getUserSharedBuffer(std::string key, MDB_val default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew); | ||
| napi_value getUserSharedBuffer(std::string key, napi_value default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew); | ||
| bool notifyUserCallbacks(std::string key); | ||
@@ -304,0 +304,0 @@ bool attemptLock(std::string key, napi_env env, napi_value func, bool has_callback, EnvWrap* ew); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2531094
-0.04%7892
-0.15%