aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-17 18:27:51 +0100
committerStefan Boberg <[email protected]>2026-03-17 18:30:14 +0100
commit512a77b5704010c087cf1dd47e419a153915fb3b (patch)
tree690b7bde2a3d37876543b344e5e1dca2db7ee2f0 /src
parentbump version to pre1 (diff)
downloadzen-512a77b5704010c087cf1dd47e419a153915fb3b.tar.xz
zen-512a77b5704010c087cf1dd47e419a153915fb3b.zip
Fix two potential SIGSEGV paths during early startup
- sentryintegration.cpp: sentry_options_new() can return nullptr on OOM; all subsequent sentry_options_set_* calls would immediately SIGSEGV. Guard with an early return that sets m_SentryErrorCode = -1 so Close() correctly skips sentry_close(). - zenserver.cpp: ZenServerState::Register() returns nullptr if the shared memory entry table is full. The subsequent Entry->SignalHasInstanceInfo(), Entry->SignalNoNetwork(), Entry->AddSponsorProcess(), and DoRun(Entry) calls would all SIGSEGV. Throw a descriptive runtime_error instead, which is caught by the existing catch handlers in Run().
Diffstat (limited to 'src')
-rw-r--r--src/zencore/sentryintegration.cpp8
-rw-r--r--src/zenserver/zenserver.cpp6
2 files changed, 14 insertions, 0 deletions
diff --git a/src/zencore/sentryintegration.cpp b/src/zencore/sentryintegration.cpp
index 58b76783a..6b093f90b 100644
--- a/src/zencore/sentryintegration.cpp
+++ b/src/zencore/sentryintegration.cpp
@@ -246,6 +246,14 @@ SentryIntegration::Initialize(const Config& Conf, const std::string& CommandLine
}
sentry_options_t* SentryOptions = sentry_options_new();
+ if (SentryOptions == nullptr)
+ {
+ // OOM — skip sentry entirely rather than crashing on the subsequent set calls
+ m_SentryErrorCode = -1;
+ m_IsInitialized = true;
+ return;
+ }
+
sentry_options_set_dsn(SentryOptions, Conf.Dsn.empty() ? sentry::DefaultDsn.c_str() : Conf.Dsn.c_str());
sentry_options_set_database_path(SentryOptions, SentryDatabasePath.c_str());
sentry_options_set_logger(SentryOptions, SentryLogFunction, this);
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 38cd5fc75..348e87740 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -730,6 +730,12 @@ ZenServerMain::Run()
Entry = ServerState.Register(m_ServerOptions.BasePort);
+ if (!Entry)
+ {
+ throw std::runtime_error(
+ fmt::format("Failed to register server on port {} in shared state (all slots occupied)", m_ServerOptions.BasePort));
+ }
+
if (m_ServerOptions.OwnerPid)
{
// We are adding a sponsor process to our own entry, can't wait for pick since the code is not run until later