2016-12-15 10:46:18 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/Bootstrap.h"
|
|
|
|
#include "nsXPCOM.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class BootstrapImpl final : public Bootstrap
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual void Dispose() override
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
BootstrapImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~BootstrapImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NS_LogInit() override {
|
|
|
|
::NS_LogInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NS_LogTerm() override {
|
|
|
|
::NS_LogTerm();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_TelemetryAccumulate(int aID, uint32_t aSample) override {
|
|
|
|
::XRE_TelemetryAccumulate(aID, aSample);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_StartupTimelineRecord(int aEvent, mozilla::TimeStamp aWhen) override {
|
|
|
|
::XRE_StartupTimelineRecord(aEvent, aWhen);
|
|
|
|
}
|
|
|
|
|
2017-01-10 10:43:23 +03:00
|
|
|
virtual int XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig) override {
|
|
|
|
return ::XRE_main(argc, argv, aConfig);
|
2016-12-15 10:46:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_StopLateWriteChecks() override {
|
|
|
|
::XRE_StopLateWriteChecks();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int XRE_XPCShellMain(int argc, char** argv, char** envp, const XREShellData* aShellData) override {
|
|
|
|
return ::XRE_XPCShellMain(argc, argv, envp, aShellData);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual GeckoProcessType XRE_GetProcessType() override {
|
|
|
|
return ::XRE_GetProcessType();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_SetProcessType(const char* aProcessTypeString) override {
|
|
|
|
::XRE_SetProcessType(aProcessTypeString);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsresult XRE_InitChildProcess(int argc, char* argv[], const XREChildData* aChildData) override {
|
|
|
|
return ::XRE_InitChildProcess(argc, argv, aChildData);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_EnableSameExecutableForContentProc() override {
|
|
|
|
::XRE_EnableSameExecutableForContentProc();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
virtual void GeckoStart(JNIEnv* aEnv, char** argv, int argc, const StaticXREAppData& aAppData) override {
|
|
|
|
::GeckoStart(aEnv, argv, argc, aAppData);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void XRE_SetAndroidChildFds(int aCrashFd, int aIPCFd) override {
|
|
|
|
::XRE_SetAndroidChildFds(aCrashFd, aIPCFd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef LIBFUZZER
|
Bug 1330533 - Remove argc/argv arguments to XRE_LibFuzzerSetMain. r=decoder
The function given to XRE_LibFuzzerSetMain is called from somewhere that
does have access to argc/argv already, so we can avoid passing them
to XRE_LibFuzzerSetMain.
This actually might fix subtle issues with argc/argv not really matching
reality when calling the LibFuzzerMain function in the current code:
some arguments are handled before the call, and both argc and argv are
modified from within XRE_main, but the values stored for the
LibFuzzerMain call still are the original ones.
Argv being a pointer, and it not being reallocated, the value stored for
the LibFuzzerMain call points to the changed one, but argc, being an
integer, is not modified accordingly.
In fact, it's actually worse, because while the Gecko code doesn't
reallocate argv, gtk_main might. So if some GTK flag is passed on the
command line, there's also a possibility that the LibFuzzerMain function
will do a use-after-free.
So all in all, it's just better to use the set of modified argc/argv
from XRE_main instead of storing them from main().
--HG--
extra : rebase_source : 92b89909eab0fc2f67ce372b959bb0e3ed12cd2b
2017-01-12 05:59:37 +03:00
|
|
|
virtual void XRE_LibFuzzerSetMain(LibFuzzerMain aMain) override {
|
|
|
|
::XRE_LibFuzzerSetMain(aMain);
|
2016-12-15 10:46:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_IPDL_TESTS
|
|
|
|
virtual int XRE_RunIPDLTest(int argc, char **argv) override {
|
|
|
|
return ::XRE_RunIPDLTest(argc, argv);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" NS_EXPORT void NS_FROZENCALL
|
|
|
|
XRE_GetBootstrap(Bootstrap::UniquePtr& b)
|
|
|
|
{
|
|
|
|
static bool sBootstrapInitialized = false;
|
|
|
|
MOZ_RELEASE_ASSERT(!sBootstrapInitialized);
|
|
|
|
|
|
|
|
sBootstrapInitialized = true;
|
|
|
|
b.reset(new BootstrapImpl());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|