tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 20dcf0f1e43bff3123a2ea14a8d824954d46356c
parent 7d9b80848500fd113036e1f54316a4ce0863b6d2
Author: Florian Queze <florian@queze.net>
Date:   Fri,  3 Oct 2025 19:56:50 +0000

Bug 1992258 - Make WindowProc marker message names searchable and avoid recording characters typed, r=mstange,win-reviewers,handyman.

Differential Revision: https://phabricator.services.mozilla.com/D267315

Diffstat:
Mwidget/windows/nsWindowDbg.cpp | 18+++++++++++++++++-
Mwidget/windows/nsWindowDbg.h | 2++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/widget/windows/nsWindowDbg.cpp b/widget/windows/nsWindowDbg.cpp @@ -89,6 +89,8 @@ struct WindowProcMarker { using MS = MarkerSchema; MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; schema.AddKeyFormat("uMsg", MS::Format::Integer); + // Add name as a hidden field to make it searchable + schema.AddKeyFormat("name", MS::Format::String, MS::PayloadFlags::Hidden); schema.SetChartLabel( "{marker.data.messageLoop} | {marker.data.name} ({marker.data.uMsg})"); schema.SetTableLabel( @@ -110,6 +112,20 @@ AutoProfilerMessageMarker::AutoProfilerMessageMarker( Span<const char> aMsgLoopName, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) : mMsgLoopName(aMsgLoopName), mMsg(msg), mWParam(wParam), mLParam(lParam) { + // Sanitize wParam for keyboard messages that might contain sensitive data + // Char messages contain actual character data + if (msg == WM_CHAR || msg == WM_SYSCHAR || msg == WM_IME_CHAR) { + mWParam = 0; + } else if (msg == WM_KEYDOWN || msg == WM_KEYUP) { + // Key messages: only sanitize printable character keys + if ((wParam >= 0x30 && wParam <= 0x39) || // 0-9 + (wParam >= 0x41 && wParam <= 0x5A) || // A-Z + (wParam >= 0xBA && wParam <= 0xE4) || // Punctuation + (wParam == 0x20)) { // Space + mWParam = 0; + } + } + if (profiler_thread_is_being_profiled_for_markers()) { mOptions.emplace(MarkerOptions(MarkerTiming::IntervalStart())); nsWindow* win = WinUtils::GetNSWindowPtr(hWnd); @@ -179,7 +195,7 @@ NativeEventLogger::NativeEventLogger(Span<const char> aMsgLoopName, HWND hwnd, mMsgLoopName(aMsgLoopName.data()), mHwnd(hwnd), mMsg(msg), - mWParam(wParam), + mWParam(mProfilerMarker.WParam()), mLParam(lParam), mResult(mozilla::Nothing()), mShouldLogPostCall(false) { diff --git a/widget/windows/nsWindowDbg.h b/widget/windows/nsWindowDbg.h @@ -35,6 +35,8 @@ class MOZ_RAII AutoProfilerMessageMarker { ~AutoProfilerMessageMarker(); + WPARAM WParam() const { return mWParam; } + protected: Maybe<MarkerOptions> mOptions; Span<const char> mMsgLoopName;