/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
/* This source code was derived from Chromium code, and as such is also subject
* to the [Chromium license](ipc/chromium/src/LICENSE). */
#ifdef FUZZING # include "mozilla/ipc/SharedMemoryFuzzer.h" #endif
namespace mozilla::ipc::shared_memory {
class MappingReporter final : public nsIMemoryReporter {
~MappingReporter() = default;
public: static Atomic<size_t> mapped;
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override {
MOZ_COLLECT_REPORT( "shmem-mapped", KIND_OTHER, UNITS_BYTES, mapped, "Memory shared with other processes that is mapped into the address " "space.");
LeakedMapping MappingBase::release() && { // NOTE: this doesn't reduce gShmemMapped since it _is_ still mapped memory // (and will be until the process terminates). return LeakedMapping{static_cast<uint8_t*>(std::exchange(mMemory, nullptr)),
std::exchange(mSize, 0)};
}
bool MappingBase::Map(const HandleBase& aHandle, void* aFixedAddress, bool aReadOnly) { // Verify that the handle size can be stored as a mapping size first // (otherwise it won't be possible to map in the address space and the Map // call will fail).
CheckedInt<size_t> checkedSize(aHandle.Size()); if (!checkedSize.isValid()) {
MOZ_LOG_FMT(gSharedMemoryLog, LogLevel::Warning, "handle size to map exceeds address space size"); returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.