From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- xpcom/build/PoisonIOInterposer.h | 14 ++++++++++---- xpcom/build/PoisonIOInterposerBase.cpp | 25 +++++++++++++------------ xpcom/build/PoisonIOInterposerWin.cpp | 3 +-- xpcom/build/XREShellData.h | 6 ++++++ 4 files changed, 30 insertions(+), 18 deletions(-) (limited to 'xpcom/build') diff --git a/xpcom/build/PoisonIOInterposer.h b/xpcom/build/PoisonIOInterposer.h index 20adeb835b..3217027b9a 100644 --- a/xpcom/build/PoisonIOInterposer.h +++ b/xpcom/build/PoisonIOInterposer.h @@ -10,6 +10,12 @@ #include "mozilla/Types.h" #include +#ifdef _WIN32 +typedef void* platform_handle_t; +#else +typedef int platform_handle_t; +#endif + MOZ_BEGIN_EXTERN_C /** Register file handle to be ignored by poisoning IO interposer. This function @@ -18,7 +24,7 @@ MOZ_BEGIN_EXTERN_C * when one of them links the static CRT). In such cases, giving file * descriptors or FILEs * doesn't work because _get_osfhandle fails with "invalid parameter". */ -void MozillaRegisterDebugHandle(intptr_t aHandle); +void MozillaRegisterDebugHandle(platform_handle_t aHandle); /** Register file descriptor to be ignored by poisoning IO interposer */ void MozillaRegisterDebugFD(int aFd); @@ -27,7 +33,7 @@ void MozillaRegisterDebugFD(int aFd); void MozillaRegisterDebugFILE(FILE* aFile); /** Unregister file handle from being ignored by poisoning IO interposer */ -void MozillaUnRegisterDebugHandle(intptr_t aHandle); +void MozillaUnRegisterDebugHandle(platform_handle_t aHandle); /** Unregister file descriptor from being ignored by poisoning IO interposer */ void MozillaUnRegisterDebugFD(int aFd); @@ -45,7 +51,7 @@ namespace mozilla { /** * Check if a file is registered as a debug file. */ -bool IsDebugFile(intptr_t aFileID); +bool IsDebugFile(platform_handle_t aFileID); /** * Initialize IO poisoning, this is only safe to do on the main-thread when no @@ -79,7 +85,7 @@ void ClearPoisonIOInterposer(); # ifdef __cplusplus namespace mozilla { -inline bool IsDebugFile(intptr_t aFileID) { return true; } +inline bool IsDebugFile(platform_handle_t aFileID) { return true; } inline void InitPoisonIOInterposer() {} inline void ClearPoisonIOInterposer() {} # ifdef XP_MACOSX diff --git a/xpcom/build/PoisonIOInterposerBase.cpp b/xpcom/build/PoisonIOInterposerBase.cpp index 0a25a3d1f8..268c5672a8 100644 --- a/xpcom/build/PoisonIOInterposerBase.cpp +++ b/xpcom/build/PoisonIOInterposerBase.cpp @@ -21,17 +21,18 @@ // Auxiliary method to convert file descriptors to ids #if defined(XP_WIN) # include -inline mozilla::Maybe FileDescriptorToHandle(int aFd) { +inline mozilla::Maybe FileDescriptorToHandle(int aFd) { intptr_t handle = _get_osfhandle(aFd); if ((handle == -1) || (handle == -2)) { // -1: Invalid handle. -2: stdin/out/err not associated with a stream. return mozilla::Nothing(); } - return mozilla::Some(handle); + return mozilla::Some( + reinterpret_cast(handle)); } #else -inline mozilla::Maybe FileDescriptorToHandle(int aFd) { - return mozilla::Some(aFd); +inline mozilla::Maybe FileDescriptorToHandle(int aFd) { + return mozilla::Some(static_cast(aFd)); } #endif /* if not XP_WIN */ @@ -161,7 +162,7 @@ class ChunkedList { } }; -typedef ChunkedList FdList; +typedef ChunkedList FdList; // Return a list used to hold the IDs of the current debug files. On unix // an ID is a file descriptor. On Windows it is a file HANDLE. @@ -176,7 +177,7 @@ namespace mozilla { // Auxiliary Method to test if a file descriptor is registered to be ignored // by the poisoning IO interposer -bool IsDebugFile(intptr_t aFileID) { +bool IsDebugFile(platform_handle_t aFileID) { return getDebugFileIDs().Contains(aFileID); } @@ -184,7 +185,7 @@ bool IsDebugFile(intptr_t aFileID) { extern "C" { -void MozillaRegisterDebugHandle(intptr_t aHandle) { +void MozillaRegisterDebugHandle(platform_handle_t aHandle) { DebugFilesAutoLock lockedScope; FdList& DebugFileIDs = getDebugFileIDs(); MOZ_ASSERT(!DebugFileIDs.Contains(aHandle)); @@ -192,7 +193,7 @@ void MozillaRegisterDebugHandle(intptr_t aHandle) { } void MozillaRegisterDebugFD(int aFd) { - mozilla::Maybe handle = FileDescriptorToHandle(aFd); + mozilla::Maybe handle = FileDescriptorToHandle(aFd); if (!handle.isSome()) { return; } @@ -207,7 +208,7 @@ void MozillaRegisterDebugFILE(FILE* aFile) { MozillaRegisterDebugFD(fd); } -void MozillaUnRegisterDebugHandle(intptr_t aHandle) { +void MozillaUnRegisterDebugHandle(platform_handle_t aHandle) { DebugFilesAutoLock lockedScope; FdList& DebugFileIDs = getDebugFileIDs(); MOZ_ASSERT(DebugFileIDs.Contains(aHandle)); @@ -215,7 +216,7 @@ void MozillaUnRegisterDebugHandle(intptr_t aHandle) { } void MozillaUnRegisterDebugFD(int aFd) { - mozilla::Maybe handle = FileDescriptorToHandle(aFd); + mozilla::Maybe handle = FileDescriptorToHandle(aFd); if (!handle.isSome()) { return; } @@ -234,11 +235,11 @@ void MozillaUnRegisterDebugFILE(FILE* aFile) { } // extern "C" #ifdef MOZ_REPLACE_MALLOC -void mozilla::DebugFdRegistry::RegisterHandle(intptr_t aHandle) { +void mozilla::DebugFdRegistry::RegisterHandle(platform_handle_t aHandle) { MozillaRegisterDebugHandle(aHandle); } -void mozilla::DebugFdRegistry::UnRegisterHandle(intptr_t aHandle) { +void mozilla::DebugFdRegistry::UnRegisterHandle(platform_handle_t aHandle) { MozillaUnRegisterDebugHandle(aHandle); } #endif diff --git a/xpcom/build/PoisonIOInterposerWin.cpp b/xpcom/build/PoisonIOInterposerWin.cpp index ad9a11dbb1..7c37a8cfe1 100644 --- a/xpcom/build/PoisonIOInterposerWin.cpp +++ b/xpcom/build/PoisonIOInterposerWin.cpp @@ -127,8 +127,7 @@ class WinIOAutoObservation : public mozilla::IOInterposeObserver::Observation { WinIOAutoObservation(mozilla::IOInterposeObserver::Operation aOp, HANDLE aFileHandle, const LARGE_INTEGER* aOffset) : mozilla::IOInterposeObserver::Observation( - aOp, sReference, - !mozilla::IsDebugFile(reinterpret_cast(aFileHandle))), + aOp, sReference, !mozilla::IsDebugFile(aFileHandle)), mFileHandle(aFileHandle), mFileHandleType(GetFileType(aFileHandle)), mHasQueriedFilename(false) { diff --git a/xpcom/build/XREShellData.h b/xpcom/build/XREShellData.h index a0f736f658..8fa47ab459 100644 --- a/xpcom/build/XREShellData.h +++ b/xpcom/build/XREShellData.h @@ -10,6 +10,9 @@ #if defined(LIBFUZZER) # include "FuzzerRegistry.h" // LibFuzzerDriver #endif +#if defined(AFLFUZZ) +# include "FuzzingInterface.h" // FuzzingTestFuncRaw +#endif #if defined(XP_WIN) && defined(MOZ_SANDBOX) namespace sandbox { @@ -34,6 +37,9 @@ struct XREShellData { #if defined(LIBFUZZER) LibFuzzerDriver fuzzerDriver; #endif +#if defined(AFLFUZZ) + int (*fuzzerDriver)(FuzzingTestFuncRaw); +#endif }; #endif // XREShellData_h -- cgit v1.2.3