[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-38.1.0esr-5.0-1] fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent
commit 9467a9d330a20b6850f7393185aec5d08e903df1
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date: Fri Aug 7 18:18:04 2015 -0700
fixup! Bug 15646: Prevent keyboard layout fingerprinting in KeyboardEvent
---
dom/events/KeyCodeConsensus.h | 37 +++++++++++++++++++------------------
dom/events/KeyboardEvent.cpp | 5 +++--
2 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/dom/events/KeyCodeConsensus.h b/dom/events/KeyCodeConsensus.h
index 53ec7f6..47d8341 100644
--- a/dom/events/KeyCodeConsensus.h
+++ b/dom/events/KeyCodeConsensus.h
@@ -9,9 +9,9 @@
// KEY_INTERNAL is called by KEY or SHIFT.
#define KEY_INTERNAL(key, code, keyCode, shift) \
- gCodes->Put(NS_LITERAL_STRING(key), NS_LITERAL_STRING(#code)); \
- gKeyCodes->Put(NS_LITERAL_STRING(key), keyCode); \
- gShiftStates->Put(NS_LITERAL_STRING(key), shift);
+ gCodes->Put(NS_LITERAL_STRING(key), NS_LITERAL_STRING(#code)); \
+ gKeyCodes->Put(NS_LITERAL_STRING(key), keyCode); \
+ gShiftStates->Put(NS_LITERAL_STRING(key), shift);
// KEY and SHIFT assign a consensus codeName and keyCode for the given keyName.
// KEY indicates that shift is off.
@@ -29,7 +29,7 @@ static nsDataHashtable<nsStringHashKey, bool>* gShiftStates;
static StaticMutex createKeyCodesMutex;
-// Populate the global static maps gCodes, gKeCodes, gShiftStates
+// Populate the global static maps gCodes, gKeyCodes, gShiftStates
// with their constant values.
static void createKeyCodes()
{
@@ -41,32 +41,33 @@ static void createKeyCodes()
gKeyCodes = new nsDataHashtable<nsStringHashKey, uint32_t>();
gShiftStates = new nsDataHashtable<nsStringHashKey, bool>();
- KEY("AltLeft", AltLeft, 18)
- KEY("AltRight", AltRight, 18)
+ KEY("Alt", AltLeft, 18)
+ KEY("ArrowDown", ArrowDown, 40)
+ KEY("ArrowLeft", ArrowLeft, 37)
+ KEY("ArrowRight", ArrowRight, 39)
+ KEY("ArrowUp", ArrowUp, 38)
+ KEY("Backspace", Backspace, 8)
KEY("CapsLock", CapsLock, 20)
- KEY("Control", ControlLeft, 17)
- KEY("Meta", OSLeft, 91)
- KEY("Shift", ShiftLeft, 16)
KEY("ContextMenu", ContextMenu, 93)
- KEY("Enter", Enter, 13)
- KEY(" ", Space, 32)
- KEY("Tab", Tab, 9)
+ KEY("Control", ControlLeft, 17)
KEY("Delete", Delete, 46)
KEY("End", End, 35)
+ KEY("Enter", Enter, 13)
+ KEY("Escape", Escape, 27)
KEY("Help", Help, 6)
KEY("Home", Home, 36)
KEY("Insert", Insert, 45)
+ KEY("Meta", OSLeft, 91)
KEY("PageDown", PageDown, 34)
KEY("PageUp", PageUp, 33)
- KEY("ArrowDown", ArrowDown, 40)
- KEY("ArrowLeft", ArrowLeft, 37)
- KEY("ArrowRight", ArrowRight, 39)
- KEY("ArrowUp", ArrowUp, 38)
- KEY("Escape", Escape, 27)
+ KEY("Pause", Pause, 19)
KEY("PrintScreen", PrintScreen, 44)
KEY("ScrollLock", ScrollLock, 145)
- KEY("Pause", Pause, 19)
+ KEY("Shift", ShiftLeft, 16)
+ KEY("Tab", Tab, 9)
+ // Leaving "Clear" key unimplemented; it's inconsistent between platforms.
+ KEY(" ", Space, 32)
KEY(",", Comma, 188)
SHIFT("<", Comma, 188)
KEY(".", Period, 190)
diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp
index 6a68f96..19d4e73 100644
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -50,8 +50,9 @@ KeyboardEvent::AltKey()
if (ResistFingerprinting()) {
nsString keyName;
GetKey(keyName);
- bool exists = gCodes->Get(keyName, nullptr);
- return exists ? false : altState;
+ bool fakeShiftState;
+ gShiftStates->Get(keyName, &fakeShiftState);
+ return fakeShiftState ? false : altState;
} else {
return altState;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits