Skip to content

Commit

Permalink
Secure parsing of WEBKIT_WPE_BMALLOC_MICROSECONDS_SLEEP env var
Browse files Browse the repository at this point in the history
  • Loading branch information
pgorszkowski-igalia committed Dec 16, 2024
1 parent 3ff7751 commit 736795d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/bmalloc/bmalloc/Mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <mach/mach_traps.h>
#include <mach/thread_switch.h>
#endif
#include <cstring>
#include <thread>
#include <unistd.h>

Expand All @@ -46,7 +47,8 @@ static inline void yield()
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
const char* env = getenv("WEBKIT_WPE_BMALLOC_MICROSECONDS_SLEEP");
if (env) {
const auto envLen = strlen(env);
if (env && envLen <= 5 && env[envLen] == '\0') {
int value;
if (sscanf(env, "%d", &value) == 1 && value > 0)
bmallocMicrosecondsSleep = value;
Expand Down

0 comments on commit 736795d

Please sign in to comment.