tbb-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 18605 discussions

[torbutton/master] Bug 20111: use Unix domain sockets for SOCKS port by default
by gkï¼ torproject.org 20 Oct '16
by gkï¼ torproject.org 20 Oct '16
20 Oct '16
commit f4980a6c647ea780eacc922846e81c0d992cbd13
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Tue Oct 11 15:37:47 2016 -0400
Bug 20111: use Unix domain sockets for SOCKS port by default
Retrieve SOCKS port configuration from Tor Launcher if available.
Support the TOR_SOCKS_IPC_PATH environment variable.
Consistently use IPC to refer to Unix domain sockets.
Enhance torbutton_local_tor_check() to correctly handle spaces and
escaped characters within the 'GETINFO net/listeners/socks' response.
Within startup-observer.js, use Services.jsm, Cc and similar
constants, and remove unused code.
---
src/chrome/content/tor-circuit-display.js | 12 +--
src/chrome/content/torbutton.js | 64 +++++++++-------
src/components/startup-observer.js | 117 +++++++++++++++++++-----------
src/modules/tor-control-port.js | 51 +++++++------
src/modules/utils.js | 101 +++++++++++++++++++++++++-
5 files changed, 242 insertions(+), 103 deletions(-)
diff --git a/src/chrome/content/tor-circuit-display.js b/src/chrome/content/tor-circuit-display.js
index f1cf2aa..c58c6d7 100644
--- a/src/chrome/content/tor-circuit-display.js
+++ b/src/chrome/content/tor-circuit-display.js
@@ -6,7 +6,7 @@
// with docco.js to produce pretty documentation.
//
// This script is to be embedded in torbutton.xul. It defines a single global
-// function, createTorCircuitDisplay(socketFile, host, port, password), which
+// function, createTorCircuitDisplay(ipcFile, host, port, password), which
// activates the automatic Tor circuit display for the current tab and any
// future tabs.
//
@@ -16,9 +16,9 @@
/* global document, gBrowser, Components */
// ### Main function
-// __createTorCircuitDisplay(socketFile, host, port, password, enablePrefName)__.
+// __createTorCircuitDisplay(ipcFile, host, port, password, enablePrefName)__.
// The single function that prepares tor circuit display. Connects to a tor
-// control port with the given socketFile or host plus port, and password, and
+// control port with the given ipcFile or host plus port, and password, and
// binds to a named bool pref whose value determines whether the circuit display
// is enabled or disabled.
let createTorCircuitDisplay = (function () {
@@ -312,11 +312,11 @@ let syncDisplayWithSelectedTab = (function() {
// ## Main function
-// __setupDisplay(socketFile, host, port, password, enablePrefName)__.
+// __setupDisplay(ipcFile, host, port, password, enablePrefName)__.
// Once called, the Tor circuit display will be started whenever
// the "enablePref" is set to true, and stopped when it is set to false.
// A reference to this function (called createTorCircuitDisplay) is exported as a global.
-let setupDisplay = function (socketFile, host, port, password, enablePrefName) {
+let setupDisplay = function (ipcFile, host, port, password, enablePrefName) {
let myController = null,
stopCollectingIsolationData = null,
stop = function() {
@@ -330,7 +330,7 @@ let setupDisplay = function (socketFile, host, port, password, enablePrefName) {
},
start = function () {
if (!myController) {
- myController = controller(socketFile, host, port || 9151, password,
+ myController = controller(ipcFile, host, port || 9151, password,
function (err) {
// An error has occurred.
logger.eclog(5, err);
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index d2824cb..9a8b9e2 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -10,6 +10,7 @@
let { LoadContextInfo } = Cu.import('resource://gre/modules/LoadContextInfo.jsm');
let { Services } = Cu.import("resource://gre/modules/Services.jsm");
let { showDialog } = Cu.import("resource://torbutton/modules/utils.js");
+let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js");
const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
@@ -33,9 +34,9 @@ var m_tb_window_width = window.outerWidth;
var m_tb_tbb = false;
-var m_tb_control_socket_file = null; // Set if using a UNIX domain socket.
-var m_tb_control_port = null; // Set if not using a socket.
-var m_tb_control_host = null; // Set if not using a socket.
+var m_tb_control_ipc_file = null; // Set if using IPC (UNIX domain socket).
+var m_tb_control_port = null; // Set if using TCP.
+var m_tb_control_host = null; // Set if using TCP.
var m_tb_control_pass = null;
var m_tb_control_desc = null; // For logging.
@@ -327,15 +328,15 @@ function torbutton_init() {
m_tb_control_pass = tlps.TorGetPassword(false);
} catch(e) {}
- // Try to get control port socket (an nsIFile) from Tor Launcher, since
- // Tor Launcher knows how to handle its own preferences and how to
+ // Try to get the control port IPC file (an nsIFile) from Tor Launcher,
+ // since Tor Launcher knows how to handle its own preferences and how to
// resolve relative paths.
try {
- m_tb_control_socket_file = tlps.TorGetControlSocketFile();
+ m_tb_control_ipc_file = tlps.TorGetControlIPCFile();
} catch(e) {}
- if (m_tb_control_socket_file) {
- m_tb_control_desc = m_tb_control_socket_file.path;
+ if (m_tb_control_ipc_file) {
+ m_tb_control_desc = m_tb_control_ipc_file.path;
} else {
if (environ.exists("TOR_CONTROL_PORT")) {
m_tb_control_port = environ.get("TOR_CONTROL_PORT");
@@ -438,7 +439,7 @@ function torbutton_init() {
torbutton_notify_if_update_needed();
torbutton_update_sync_ui();
- createTorCircuitDisplay(m_tb_control_socket_file, m_tb_control_host,
+ createTorCircuitDisplay(m_tb_control_ipc_file, m_tb_control_host,
m_tb_control_port, m_tb_control_pass,
"extensions.torbutton.display_circuit");
@@ -1009,8 +1010,8 @@ function torbutton_send_ctrl_cmd(command) {
let sts = Cc["@mozilla.org/network/socket-transport-service;1"]
.getService(Ci.nsISocketTransportService);
let socket;
- if (m_tb_control_socket_file) {
- socket = sts.createUnixDomainTransport(m_tb_control_socket_file);
+ if (m_tb_control_ipc_file) {
+ socket = sts.createUnixDomainTransport(m_tb_control_ipc_file);
} else {
socket = sts.createTransport(null, 0, m_tb_control_host,
m_tb_control_port, null);
@@ -1350,7 +1351,7 @@ function torbutton_do_new_identity() {
torbutton_log(3, "New Identity: Sending NEWNYM");
// We only support TBB for newnym.
- if (!m_tb_control_pass || (!m_tb_control_socket_file && !m_tb_control_port)) {
+ if (!m_tb_control_pass || (!m_tb_control_ipc_file && !m_tb_control_port)) {
var warning = torbutton_get_property_string("torbutton.popup.no_newnym");
torbutton_log(5, "Torbutton cannot safely newnym. It does not have access to the Tor Control Port.");
window.alert(warning);
@@ -1508,7 +1509,7 @@ function torbutton_do_tor_check()
const kEnvUseTransparentProxy = "TOR_TRANSPROXY";
var env = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment);
- if ((m_tb_control_socket_file || m_tb_control_port) &&
+ if ((m_tb_control_ipc_file || m_tb_control_port) &&
!env.exists(kEnvUseTransparentProxy) &&
!env.exists(kEnvSkipControlPortTest) &&
m_tb_prefs.getBoolPref("extensions.torbutton.local_tor_check")) {
@@ -1559,19 +1560,20 @@ function torbutton_local_tor_check()
}
// Sample response: net/listeners/socks="127.0.0.1:9149" "127.0.0.1:9150"
- // First, check for command argument prefix.
+ // First, check for and remove the command argument prefix.
if (0 != resp.indexOf(kCmdArg + '=')) {
logUnexpectedResponse();
return false;
}
+ resp = resp.substr(kCmdArg.length + 1);
// Retrieve configured proxy settings and check each listener against them.
- // When a Unix domain socket is configured, a file URL should be present in
- // network.proxy.socks.
+ // When the SOCKS prefs are set to use IPC (e.g., a Unix domain socket), a
+ // file URL should be present in network.proxy.socks.
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1211567
let socksAddr = m_tb_prefs.getCharPref("network.proxy.socks");
let socksPort = m_tb_prefs.getIntPref("network.proxy.socks_port");
- let socketPath;
+ let socksIPCPath;
if (socksAddr && socksAddr.startsWith("file:")) {
// Convert the file URL to a file path.
try {
@@ -1579,19 +1581,29 @@ function torbutton_local_tor_check()
.getService(Ci.nsIIOService);
let fph = ioService.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler);
- socketPath = fph.getFileFromURLSpec(socksAddr).path;
+ socksIPCPath = fph.getFileFromURLSpec(socksAddr).path;
} catch (e) {
- torbutton_log(5, "Local Tor check: Unix domain socket error: " + e);
+ torbutton_log(5, "Local Tor check: IPC file error: " + e);
return false;
}
} else {
socksAddr = removeBrackets(socksAddr);
}
- let addrArray = resp.substr(kCmdArg.length + 1).split(' ');
+ // Split into quoted strings. This code is adapted from utils.splitAtSpaces()
+ // within tor-control-port.js; someday this code should use the entire
+ // tor-control-port.js framework.
+ let addrArray = [];
+ resp.replace(/((\S*?"(.*?)")+\S*|\S+)/g, function (a, captured) {
+ addrArray.push(captured);
+ });
+
let foundSocksListener = false;
for (let i = 0; !foundSocksListener && (i < addrArray.length); ++i) {
- let addr = addrArray[i];
+ let addr;
+ try { addr = unescapeTorString(addrArray[i]); } catch (e) {}
+ if (!addr)
+ continue;
// Remove double quotes if present.
let len = addr.length;
@@ -1599,14 +1611,14 @@ function torbutton_local_tor_check()
addr = addr.substring(1, len - 1);
if (addr.startsWith("unix:")) {
- if (!socketPath)
+ if (!socksIPCPath)
continue;
// Check against the configured UNIX domain socket proxy.
let path = addr.substring(5);
- torbutton_log(2, "Tor socks listener (socket): " + path);
- foundSocksListener = (socketPath === path);
- } else if (!socketPath) {
+ torbutton_log(2, "Tor socks listener (Unix domain socket): " + path);
+ foundSocksListener = (socksIPCPath === path);
+ } else if (!socksIPCPath) {
// Check against the configured TCP proxy. We expect addr:port where addr
// may be an IPv6 address; that is, it may contain colon characters.
// Also, we remove enclosing square brackets before comparing addresses
@@ -2088,7 +2100,7 @@ function torbutton_check_protections()
// See https://trac.torproject.org/projects/tor/ticket/10353 for more info.
document.getElementById("torbutton-cookie-protector").hidden = m_tb_prefs.getBoolPref("browser.privatebrowsing.autostart");
- if (!m_tb_control_pass || (!m_tb_control_socket_file && !m_tb_control_port)) {
+ if (!m_tb_control_pass || (!m_tb_control_ipc_file && !m_tb_control_port)) {
document.getElementById("torbutton-new-identity").disabled = true;
}
diff --git a/src/components/startup-observer.js b/src/components/startup-observer.js
index f083482..6698b0b 100644
--- a/src/components/startup-observer.js
+++ b/src/components/startup-observer.js
@@ -15,6 +15,13 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
+ "resource://gre/modules/FileUtils.jsm");
+
// Module specific constants
const kMODULE_NAME = "Startup";
@@ -22,10 +29,9 @@ const kMODULE_CONTRACTID = "@torproject.org/startup-observer;1";
const kMODULE_CID = Components.ID("06322def-6fde-4c06-aef6-47ae8e799629");
function StartupObserver() {
- this.logger = Components.classes["@torproject.org/torbutton-logger;1"]
- .getService(Components.interfaces.nsISupports).wrappedJSObject;
- this._prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
+ this.logger = Cc["@torproject.org/torbutton-logger;1"]
+ .getService(Ci.nsISupports).wrappedJSObject;
+ this._prefs = Services.prefs;
this.logger.log(3, "Startup Observer created");
var env = Cc["@mozilla.org/process/environment;1"]
@@ -61,41 +67,74 @@ StartupObserver.prototype = {
// some weird proxy caching code that showed up in FF15.
// Otherwise, homepage domain loads fail forever.
setProxySettings: function() {
+ if (!this.is_tbb)
+ return;
+
// Bug 1506: Still want to get these env vars
- var environ = Components.classes["@mozilla.org/process/environment;1"]
- .getService(Components.interfaces.nsIEnvironment);
-
- if (environ.exists("TOR_SOCKS_PORT")) {
- if (this.is_tbb) {
- this._prefs.setIntPref('network.proxy.socks_port',
- parseInt(environ.get("TOR_SOCKS_PORT")));
- this._prefs.setBoolPref('network.proxy.socks_remote_dns', true);
- this._prefs.setIntPref('network.proxy.type', 1);
+ let environ = Cc["@mozilla.org/process/environment;1"]
+ .getService(Ci.nsIEnvironment);
+ if (environ.exists("TOR_TRANSPROXY")) {
+ this.logger.log(3, "Resetting Tor settings to transproxy");
+ this._prefs.setBoolPref("network.proxy.socks_remote_dns", false);
+ this._prefs.setIntPref("network.proxy.type", 0);
+ this._prefs.setIntPref("network.proxy.socks_port", 0);
+ this._prefs.setCharPref("network.proxy.socks", "");
+ } else {
+ // Try to retrieve SOCKS proxy settings from Tor Launcher.
+ let socksPortInfo;
+ try {
+ let tlps = Cc["@torproject.org/torlauncher-protocol-service;1"]
+ .getService(Ci.nsISupports).wrappedJSObject;
+ socksPortInfo = tlps.TorGetSOCKSPortInfo();
+ } catch(e) {}
+
+ // If Tor Launcher is not available, check environment variables.
+ if (!socksPortInfo) {
+ socksPortInfo = { ipcFile: undefined, host: undefined, port: 0 };
+
+ let isWindows = Services.appinfo.OS === "WINNT";
+ if (!isWindows && environ.exists("TOR_SOCKS_IPC_PATH")) {
+ socksPortInfo.ipcFile = new FileUtils.File(
+ environ.get("TOR_SOCKS_IPC_PATH"));
+ }
+ else
+ {
+ if (environ.exists("TOR_SOCKS_HOST"))
+ socksPortInfo.host = environ.get("TOR_SOCKS_HOST");
+ if (environ.exists("TOR_SOCKS_PORT"))
+ socksPortInfo.port = parseInt(environ.get("TOR_SOCKS_PORT"));
+ }
}
- this.logger.log(3, "Reset socks port to "+environ.get("TOR_SOCKS_PORT"));
- }
- if (environ.exists("TOR_SOCKS_HOST")) {
- if (this.is_tbb) {
- this._prefs.setCharPref('network.proxy.socks', environ.get("TOR_SOCKS_HOST"));
+ // Adjust network.proxy prefs.
+ if (socksPortInfo.ipcFile) {
+ let fph = Services.io.getProtocolHandler("file")
+ .QueryInterface(Ci.nsIFileProtocolHandler);
+ let fileURI = fph.newFileURI(socksPortInfo.ipcFile);
+ this.logger.log(3, "Reset socks to "+fileURI.spec);
+ this._prefs.setCharPref("network.proxy.socks", fileURI.spec);
+ this._prefs.setIntPref("network.proxy.socks_port", 0);
+ } else {
+ if (socksPortInfo.host) {
+ this._prefs.setCharPref("network.proxy.socks", socksPortInfo.host);
+ this.logger.log(3, "Reset socks host to "+socksPortInfo.host);
+ }
+ if (socksPortInfo.port) {
+ this._prefs.setIntPref("network.proxy.socks_port",
+ socksPortInfo.port);
+ this.logger.log(3, "Reset socks port to "+socksPortInfo.port);
+ }
}
- }
- if (environ.exists("TOR_TRANSPROXY")) {
- this.logger.log(3, "Resetting Tor settings to transproxy");
- if (this.is_tbb) {
- this._prefs.setBoolPref('network.proxy.socks_remote_dns', false);
- this._prefs.setIntPref('network.proxy.type', 0);
- this._prefs.setIntPref('network.proxy.socks_port', 0);
- this._prefs.setCharPref('network.proxy.socks', "");
+ if (socksPortInfo.ipcFile || socksPortInfo.host || socksPortInfo.port) {
+ this._prefs.setBoolPref("network.proxy.socks_remote_dns", true);
+ this._prefs.setIntPref("network.proxy.type", 1);
}
}
// Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
-
+ this._prefs.savePrefFile(null);
+
this.logger.log(3, "Synced network settings to environment.");
},
@@ -109,16 +148,14 @@ StartupObserver.prototype = {
}
// In all cases, force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
+ this._prefs.savePrefFile(null);
},
QueryInterface: function(iid) {
- if (iid.equals(Components.interfaces.nsISupports)) {
+ if (iid.equals(Ci.nsISupports)) {
return this;
}
- if(iid.equals(Components.interfaces.nsIClassInfo)) {
+ if(iid.equals(Ci.nsIClassInfo)) {
return this;
}
return this;
@@ -141,12 +178,4 @@ StartupObserver.prototype = {
};
-/**
-* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
-* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
-*/
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-if (XPCOMUtils.generateNSGetFactory)
- var NSGetFactory = XPCOMUtils.generateNSGetFactory([StartupObserver]);
-else
- var NSGetModule = XPCOMUtils.generateNSGetModule([StartupObserver]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([StartupObserver]);
diff --git a/src/modules/tor-control-port.js b/src/modules/tor-control-port.js
index f23daed..a7f0434 100644
--- a/src/modules/tor-control-port.js
+++ b/src/modules/tor-control-port.js
@@ -10,7 +10,7 @@
// let { controller } = Components.utils.import("path/to/tor-control-port.js");
//
// See the last function defined in this file:
-// controller(socketFile, host, port, password, onError)
+// controller(ipcFile, host, port, password, onError)
// for usage of the controller function.
/* jshint esnext: true */
@@ -42,18 +42,18 @@ log("Loading tor-control-port.js\n");
// I/O utilities namespace
let io = {};
-// __io.asyncSocketStreams(socketFile, host, port)__.
+// __io.asyncSocketStreams(ipcFile, host, port)__.
// Creates a pair of asynchronous input and output streams for a socket at the
-// given socketFile or host and port.
-io.asyncSocketStreams = function (socketFile, host, port) {
+// given ipcFile or host and port.
+io.asyncSocketStreams = function (ipcFile, host, port) {
let sts = Cc["@mozilla.org/network/socket-transport-service;1"]
.getService(Components.interfaces.nsISocketTransportService),
UNBUFFERED = Ci.nsITransport.OPEN_UNBUFFERED;
// Create an instance of a socket transport.
let socketTransport;
- if (socketFile) {
- socketTransport = sts.createUnixDomainTransport(socketFile);
+ if (ipcFile) {
+ socketTransport = sts.createUnixDomainTransport(ipcFile);
} else {
socketTransport = sts.createTransport(null, 0, host, port, null);
}
@@ -99,16 +99,15 @@ io.pumpInputStream = function (inputStream, onInputData, onError) {
} }, null);
};
-// __io.asyncSocket(socketFile, host, port, onInputData, onError)__.
-// Creates an asynchronous, text-oriented UNIX domain socket (if socketFile
-// is defined) or TCP socket at host:port.
+// __io.asyncSocket(ipcFile, host, port, onInputData, onError)__.
+// Creates an asynchronous, text-oriented IPC socket (if ipcFile is defined)
+// or a TCP socket at host:port.
// The onInputData callback should accept a single argument, which will be called
// repeatedly, whenever incoming text arrives. Returns a socket object with two methods:
// socket.write(text) and socket.close(). onError will be passed the error object
// whenever a write fails.
-io.asyncSocket = function (socketFile, host, port, onInputData, onError) {
- let [inputStream, outputStream] = io.asyncSocketStreams(socketFile, host,
- port),
+io.asyncSocket = function (ipcFile, host, port, onInputData, onError) {
+ let [inputStream, outputStream] = io.asyncSocketStreams(ipcFile, host, port),
pendingWrites = [];
// Run an input stream pump to send incoming data to the onInputData callback.
io.pumpInputStream(inputStream, onInputData, onError);
@@ -253,8 +252,8 @@ io.matchRepliesToCommands = function (asyncSend, dispatcher) {
});
};
-// __io.controlSocket(socketFile, host, port, password, onError)__.
-// Instantiates and returns a socket to a tor ControlPort at socketFile or
+// __io.controlSocket(ipcFile, host, port, password, onError)__.
+// Instantiates and returns a socket to a tor ControlPort at ipcFile or
// host:port, authenticating with the given password. onError is called with an
// error object as its single argument whenever an error occurs. Example:
//
@@ -269,11 +268,11 @@ io.matchRepliesToCommands = function (asyncSend, dispatcher) {
// socket.removeNotificationCallback(callback);
// // Close the socket permanently
// socket.close();
-io.controlSocket = function (socketFile, host, port, password, onError) {
+io.controlSocket = function (ipcFile, host, port, password, onError) {
// Produce a callback dispatcher for Tor messages.
let mainDispatcher = io.callbackDispatcher(),
// Open the socket and convert format to Tor messages.
- socket = io.asyncSocket(socketFile, host, port,
+ socket = io.asyncSocket(ipcFile, host, port,
io.onDataFromOnLine(
io.onLineFromOnMessage(mainDispatcher.pushMessage)),
onError),
@@ -620,12 +619,12 @@ let tor = {};
// redundant instantiation of control sockets.
tor.controllerCache = {};
-// __tor.controller(socketFile, host, port, password, onError)__.
-// Creates a tor controller at the given socketFile or host and port, with the
+// __tor.controller(ipcFile, host, port, password, onError)__.
+// Creates a tor controller at the given ipcFile or host and port, with the
// given password.
// onError returns asynchronously whenever a connection error occurs.
-tor.controller = function (socketFile, host, port, password, onError) {
- let socket = io.controlSocket(socketFile, host, port, password, onError),
+tor.controller = function (ipcFile, host, port, password, onError) {
+ let socket = io.controlSocket(ipcFile, host, port, password, onError),
isOpen = true;
return { getInfo : key => info.getInfo(socket, key),
getConf : key => info.getConf(socket, key),
@@ -638,11 +637,11 @@ tor.controller = function (socketFile, host, port, password, onError) {
// ## Export
-// __controller(socketFile, host, port, password, onError)__.
+// __controller(ipcFile, host, port, password, onError)__.
// Instantiates and returns a controller object connected to a tor ControlPort
-// on socketFile or at host:port, authenticating with the given password, if
+// on ipcFile or at host:port, authenticating with the given password, if
// the controller doesn't yet exist. Otherwise returns the existing controller
-// to the given socketFile or host:port.
+// to the given ipcFile or host:port.
// onError is called with an error object as its single argument whenever
// an error occurs. Example:
//
@@ -653,13 +652,13 @@ tor.controller = function (socketFile, host, port, password, onError) {
// let replyPromise = c.getInfo("ip-to-country/16.16.16.16");
// // Close the controller permanently
// c.close();
-var controller = function (socketFile, host, port, password, onError) {
- let dest = (socketFile) ? "unix:" + socketFile.path : host + ":" + port,
+var controller = function (ipcFile, host, port, password, onError) {
+ let dest = (ipcFile) ? "unix:" + ipcFile.path : host + ":" + port,
maybeController = tor.controllerCache[dest];
return (tor.controllerCache[dest] =
(maybeController && maybeController.isOpen()) ?
maybeController :
- tor.controller(socketFile, host, port, password, onError));
+ tor.controller(ipcFile, host, port, password, onError));
};
// Export the controller function for external use.
diff --git a/src/modules/utils.js b/src/modules/utils.js
index 514ef51..b303485 100644
--- a/src/modules/utils.js
+++ b/src/modules/utils.js
@@ -74,5 +74,104 @@ var showDialog = function (parent, url, name, features) {
}
};
+// ## Tor control protocol utility functions
+
+let _torControl = {
+ // Unescape Tor Control string aStr (removing surrounding "" and \ escapes).
+ // Based on Vidalia's src/common/stringutil.cpp:string_unescape().
+ // Returns the unescaped string. Throws upon failure.
+ // Within Tor Launcher, the file components/tl-protocol.js also contains a
+ // copy of _strUnescape().
+ _strUnescape: function(aStr)
+ {
+ if (!aStr)
+ return aStr;
+
+ var len = aStr.length;
+ if ((len < 2) || ('"' != aStr.charAt(0)) || ('"' != aStr.charAt(len - 1)))
+ return aStr;
+
+ const kHexRE = /[0-9A-Fa-f]{2}/;
+ const kOctalRE = /[0-7]{3}/;
+ var rv = "";
+ var i = 1;
+ var lastCharIndex = len - 2;
+ while (i <= lastCharIndex)
+ {
+ var c = aStr.charAt(i);
+ if ('\\' == c)
+ {
+ if (++i > lastCharIndex)
+ throw new Error("missing character after \\");
+
+ c = aStr.charAt(i);
+ if ('n' == c)
+ rv += '\n';
+ else if ('r' == c)
+ rv += '\r';
+ else if ('t' == c)
+ rv += '\t';
+ else if ('x' == c)
+ {
+ if ((i + 2) > lastCharIndex)
+ throw new Error("not enough hex characters");
+
+ let s = aStr.substr(i + 1, 2);
+ if (!kHexRE.test(s))
+ throw new Error("invalid hex characters");
+
+ let val = parseInt(s, 16);
+ rv += String.fromCharCode(val);
+ i += 3;
+ }
+ else if (this._isDigit(c))
+ {
+ let s = aStr.substr(i, 3);
+ if ((i + 2) > lastCharIndex)
+ throw new Error("not enough octal characters");
+
+ if (!kOctalRE.test(s))
+ throw new Error("invalid octal characters");
+
+ let val = parseInt(s, 8);
+ rv += String.fromCharCode(val);
+ i += 3;
+ }
+ else // "\\" and others
+ {
+ rv += c;
+ ++i;
+ }
+ }
+ else if ('"' == c)
+ throw new Error("unescaped \" within string");
+ else
+ {
+ rv += c;
+ ++i;
+ }
+ }
+
+ // Convert from UTF-8 to Unicode. TODO: is UTF-8 always used in protocol?
+ return decodeURIComponent(escape(rv));
+ }, // _strUnescape()
+
+ // Within Tor Launcher, the file components/tl-protocol.js also contains a
+ // copy of _isDigit().
+ _isDigit: function(aChar)
+ {
+ const kRE = /^\d$/;
+ return aChar && kRE.test(aChar);
+ },
+}; // _torControl
+
+// __unescapeTorString(str, resultObj)__.
+// Unescape Tor Control string str (removing surrounding "" and \ escapes).
+// Returns the unescaped string. Throws upon failure.
+var unescapeTorString = function(str) {
+ return _torControl._strUnescape(str);
+};
+
// Export utility functions for external use.
-let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue", "getEnv", "showDialog"];
+let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue", "getEnv",
+ "showDialog", "unescapeTorString"];
1
0
commit 70e5f3b26c7e4d22158b02757681170ac0daadf5
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Tue Oct 18 11:29:27 2016 -0700
Bug 20394: Remove obsolete code
---
src/chrome/content/contents.rdf | 50 ------------------------------------
src/chrome/content/torbutton.js | 23 ++---------------
src/chrome/content/torbutton_util.js | 8 +-----
src/chrome/skin/contents.rdf | 45 --------------------------------
4 files changed, 3 insertions(+), 123 deletions(-)
diff --git a/src/chrome/content/contents.rdf b/src/chrome/content/contents.rdf
deleted file mode 100644
index c7afa3a..0000000
--- a/src/chrome/content/contents.rdf
+++ /dev/null
@@ -1,50 +0,0 @@
-<!-- Bug 1506 P0: This is old FF2 cruft. It does not need to exist. -->
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
-
- <Seq about="urn:mozilla:package:root">
- <li resource="urn:mozilla:package:torbutton"/>
- </Seq>
-
- <Description about="urn:mozilla:package:torbutton"
- chrome:athor="Scott Squires"
- chrome:displayName="Torbutton"
- chrome:extension="true"
- chrome:name="torbutton">
- </Description>
-
- <Seq about="urn:mozilla:overlays">
- <!-- firefox 0.9 and 1.0 -->
- <li resource="chrome://browser/content/browser.xul"/>
- <li resource="chrome://browser/content/pref/pref-connection.xul"/>
- <!-- thunderbird -->
- <li resource="chrome://messenger/content/messenger.xul"/>
- <li resource="chrome://messenger/content/messengercompose/messengercompose.xul"/>
- <!-- torbutton -->
- <li resource="chrome://torbutton/content/torbutton.xul"/>
- </Seq>
-
- <!-- firefox 0.9 and 1.0 -->
- <Seq about="chrome://browser/content/browser.xul">
- <li>chrome://torbutton/content/torbutton.xul</li>
- </Seq>
- <Seq about="chrome://browser/content/pref/pref-connection.xul">
- <li>chrome://torbutton/content/pref-connection.xul</li>
- </Seq>
-
- <!-- thunderbird -->
- <Seq about="chrome://messenger/content/messenger.xul">
- <li>chrome://torbutton/content/torbutton_tb.xul</li>
- </Seq>
- <Seq about="chrome://messenger/content/messengercompose/messengercompose.xul">
- <li>chrome://torbutton/content/torbutton_tb.xul</li>
- </Seq>
-
- <!-- torbutton -->
- <Seq about="chrome://torbutton/content/torbutton.xul">
- <li>chrome://torbutton/content/popup.xul</li>
- </Seq>
-
-</RDF>
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 3c05047..d2824cb 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1,4 +1,4 @@
-// Bug 1506 P0-P5: This is the main Torbutton overlay file. Much needs to be
+// Bug 1506 P1-P5: This is the main Torbutton overlay file. Much needs to be
// preserved here, but in an ideal world, most of this code should perhaps be
// moved into an XPCOM service, and much can also be tossed. See also
// individual 1506 comments for details.
@@ -2110,25 +2110,6 @@ function torbutton_open_prefs_dialog() {
torbutton_log(2, 'opened preferences window');
}
-// Bug 1506 P0: Support code for checking Firefox versions. Not needed.
-function torbutton_gecko_compare(aVersion) {
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
- var httpProtocolHandler = ioService.getProtocolHandler("http")
- .QueryInterface(Components.interfaces.nsIHttpProtocolHandler);
- var versionComparator = null;
-
- if ("nsIVersionComparator" in Components.interfaces) {
- versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
- .getService(Components.interfaces.nsIVersionComparator);
- } else {
- versionComparator = Components.classes["@mozilla.org/updates/version-checker;1"]
- .getService(Components.interfaces.nsIVersionChecker);
- }
- var geckoVersion = httpProtocolHandler.misc.match(/rv:([0-9.]+)/)[1];
- return versionComparator.compare(aVersion, geckoVersion);
-}
-
// -------------- HISTORY & COOKIES ---------------------
// Bug 1506 P4: Used by New Identity if cookie protections are
@@ -2321,7 +2302,7 @@ function torbutton_do_startup()
}
}
-// Bug 1506 P0: Perform version check when a new tab is opened.
+// Perform version check when a new tab is opened.
function torbutton_new_tab(event)
{
// listening for new tabs
diff --git a/src/chrome/content/torbutton_util.js b/src/chrome/content/torbutton_util.js
index f1263f1..e6de768 100644
--- a/src/chrome/content/torbutton_util.js
+++ b/src/chrome/content/torbutton_util.js
@@ -1,4 +1,4 @@
-// Bug 1506 P0-P3: These utility functions might be useful, but
+// Bug 1506 P1-P3: These utility functions might be useful, but
// you probably just want to rewrite them or use the underlying
// code directly. I don't see any of them as essential for 1506,
// really.
@@ -8,12 +8,6 @@ var m_tb_torlog = Components.classes["@torproject.org/torbutton-logger;1"]
var m_tb_string_bundle = torbutton_get_stringbundle();
-// Bug 1506 P0: Use the log service directly
-function torbutton_eclog(nLevel, sMsg) {
- m_tb_torlog.eclog(nLevel, sMsg);
- return true;
-}
-
function torbutton_safelog(nLevel, sMsg, scrub) {
m_tb_torlog.safe_log(nLevel, sMsg, scrub);
return true;
diff --git a/src/chrome/skin/contents.rdf b/src/chrome/skin/contents.rdf
deleted file mode 100644
index 53bde17..0000000
--- a/src/chrome/skin/contents.rdf
+++ /dev/null
@@ -1,45 +0,0 @@
-<!-- Bug 1506 P0: This is old FF2 cruft. It does not need to exist. -->
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
-
- <Seq about="urn:mozilla:skin:root">
- <li resource="urn:mozilla:skin:classic/1.0"/>
- </Seq>
-
- <Description about="urn:mozilla:skin:classic/1.0">
- <chrome:packages>
- <Seq about="urn:mozilla:skin:classic/1.0:packages">
- <li resource="urn:mozilla:skin:classic/1.0:torbutton"/>
- </Seq>
- </chrome:packages>
- </Description>
-
- <Seq about="urn:mozilla:stylesheets">
- <li resource="chrome://global/content/customizeToolbar.xul"/>
- <!-- firefox -->
- <li resource="chrome://browser/content/browser.xul"/>
- <!-- thunderbird -->
- <li resource="chrome://messenger/content/messenger.xul"/>
- <li resource="chrome://messenger/content/messengercompose/messengercompose.xul"/>
- </Seq>
-
- <Seq about="chrome://global/content/customizeToolbar.xul">
- <li>chrome://torbutton/skin/torbutton.css</li>
- </Seq>
-
- <!-- firefox -->
- <Seq about="chrome://browser/content/browser.xul">
- <li>chrome://torbutton/skin/torbutton.css</li>
- </Seq>
-
- <!-- thunderbird -->
- <Seq about="chrome://messenger/content/messenger.xul">
- <li>chrome://torbutton/skin/torbutton.css</li>
- </Seq>
- <Seq about="chrome://messenger/content/messengercompose/messengercompose.xul">
- <li>chrome://torbutton/skin/torbutton.css</li>
- </Seq>
-
-</RDF>
1
0

[tor-browser/tor-browser-45.4.0esr-6.5-1] fixup! TB4: Tor Browser's Firefox preference overrides.
by gkï¼ torproject.org 19 Oct '16
by gkï¼ torproject.org 19 Oct '16
19 Oct '16
commit 62d6468cedbdd1ae08b1e4a7192184c3aa92137c
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Tue Oct 18 18:10:41 2016 -0700
fixup! TB4: Tor Browser's Firefox preference overrides.
Fixes #20399 by removing obsolete preferences related to our font
fingerprinting defense.
---
browser/app/profile/000-tor-browser.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/browser/app/profile/000-tor-browser.js b/browser/app/profile/000-tor-browser.js
index 13af485..1f1db9e 100644
--- a/browser/app/profile/000-tor-browser.js
+++ b/browser/app/profile/000-tor-browser.js
@@ -112,8 +112,6 @@ pref("webgl.disable-extensions", true);
pref("webgl.disable-fail-if-major-performance-caveat", true);
pref("dom.battery.enabled", false); // fingerprinting due to differing OS implementations
pref("dom.network.enabled",false); // fingerprinting due to differing OS implementations
-pref("browser.display.max_font_attempts",10);
-pref("browser.display.max_font_count",10);
pref("gfx.downloadable_fonts.fallback_delay", -1);
pref("general.appname.override", "Netscape");
pref("general.appversion.override", "5.0 (Windows)");
1
0

19 Oct '16
commit 2d88aa4d7239c3d386c69396c8d0d40ddd23a952
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Tue Oct 18 17:23:45 2016 -0700
Bug 20399: Remove obsolete font attempt prefs
---
src/chrome/content/torbutton.js | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 5b03ba0..3c05047 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1746,12 +1746,6 @@ function torbutton_update_fingerprinting_prefs() {
if (m_tb_tbb) {
if (mode) {
- // Use TBB pref defaults for these two.
- if(m_tb_prefs.prefHasUserValue("browser.display.max_font_attempts"))
- m_tb_prefs.clearUserPref("browser.display.max_font_attempts");
- if(m_tb_prefs.prefHasUserValue("browser.display.max_font_count"))
- m_tb_prefs.clearUserPref("browser.display.max_font_count");
-
// Governed also by the spoof_english dialog..
if (m_tb_prefs.getBoolPref("extensions.torbutton.spoof_english")) {
m_tb_prefs.setCharPref("intl.accept_languages", "en-US, en");
@@ -1762,9 +1756,6 @@ function torbutton_update_fingerprinting_prefs() {
m_tb_prefs.setBoolPref("javascript.use_us_english_locale", false);
}
} else {
- m_tb_prefs.setIntPref("browser.display.max_font_attempts",-1);
- m_tb_prefs.setIntPref("browser.display.max_font_count",-1);
-
if(m_tb_prefs.prefHasUserValue("intl.accept_languages"))
m_tb_prefs.clearUserPref("intl.accept_languages");
}
1
0

[torbutton/master] Bug 20388: Consolidate Services.prefs references
by gkï¼ torproject.org 18 Oct '16
by gkï¼ torproject.org 18 Oct '16
18 Oct '16
commit 2cef75462d4a7f640b4586c0cd50b6679b9fc7ae
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Mon Oct 17 14:21:36 2016 -0700
Bug 20388: Consolidate Services.prefs references
---
src/chrome/content/torbutton.js | 76 ++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 47 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index fa4009a..5b03ba0 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -18,9 +18,10 @@ const k_tb_tor_check_failed_topic = "Torbutton:TorCheckFailed";
const k_tb_tor_resize_warn_pref =
"extensions.torbutton.startup_resize_period"
+var m_tb_prefs = Services.prefs;
+
// status
var m_tb_wasinited = false;
-var m_tb_prefs = false;
var m_tb_plugin_string = false;
var m_tb_is_main_window = false;
var m_tb_hidden_browser = false;
@@ -50,16 +51,12 @@ var torbutton_window_pref_observer =
{
register: function()
{
- var pref_service = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranchInternal);
- this._branch = pref_service.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
- this._branch.addObserver("extensions.torbutton", this, false);
+ m_tb_prefs.addObserver("extensions.torbutton", this, false);
},
unregister: function()
{
- if (!this._branch) return;
- this._branch.removeObserver("extensions.torbutton", this);
+ m_tb_prefs.removeObserver("extensions.torbutton", this);
},
// topic: what event occurred
@@ -84,21 +81,18 @@ var torbutton_unique_pref_observer =
register: function()
{
this.forced_ua = false;
- var pref_service = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranchInternal);
- this._branch = pref_service.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
- this._branch.addObserver("extensions.torbutton", this, false);
- this._branch.addObserver("network.cookie", this, false);
- this._branch.addObserver("browser.privatebrowsing.autostart", this, false);
- this._branch.addObserver("javascript", this, false);
- this._branch.addObserver("gfx", this, false);
- this._branch.addObserver("noscript", this, false);
- this._branch.addObserver("media", this, false);
- this._branch.addObserver("mathml", this, false);
- this._branch.addObserver("svg", this, false);
- this._branch.addObserver("plugin.disable", this, false);
- this._branch.addObserver("privacy.thirdparty.isolate", this, false);
- this._branch.addObserver("privacy.resistFingerprinting", this, false);
+ m_tb_prefs.addObserver("extensions.torbutton", this, false);
+ m_tb_prefs.addObserver("network.cookie", this, false);
+ m_tb_prefs.addObserver("browser.privatebrowsing.autostart", this, false);
+ m_tb_prefs.addObserver("javascript", this, false);
+ m_tb_prefs.addObserver("gfx", this, false);
+ m_tb_prefs.addObserver("noscript", this, false);
+ m_tb_prefs.addObserver("media", this, false);
+ m_tb_prefs.addObserver("mathml", this, false);
+ m_tb_prefs.addObserver("svg", this, false);
+ m_tb_prefs.addObserver("plugin.disable", this, false);
+ m_tb_prefs.addObserver("privacy.thirdparty.isolate", this, false);
+ m_tb_prefs.addObserver("privacy.resistFingerprinting", this, false);
// We observe xpcom-category-entry-added for plugins w/ Gecko-Content-Viewers
var observerService = Cc["@mozilla.org/observer-service;1"].
@@ -108,16 +102,15 @@ var torbutton_unique_pref_observer =
unregister: function()
{
- if (!this._branch) return;
- this._branch.removeObserver("extensions.torbutton", this);
- this._branch.removeObserver("network.cookie", this);
- this._branch.removeObserver("browser.privatebrowsing.autostart", this);
- this._branch.removeObserver("javascript", this);
- this._branch.removeObserver("gfx", this);
- this._branch.removeObserver("noscript", this);
- this._branch.removeObserver("media", this);
- this._branch.removeObserver("mathml", this);
- this._branch.removeObserver("svg", this);
+ m_tb_prefs.removeObserver("extensions.torbutton", this);
+ m_tb_prefs.removeObserver("network.cookie", this);
+ m_tb_prefs.removeObserver("browser.privatebrowsing.autostart", this);
+ m_tb_prefs.removeObserver("javascript", this);
+ m_tb_prefs.removeObserver("gfx", this);
+ m_tb_prefs.removeObserver("noscript", this);
+ m_tb_prefs.removeObserver("media", this);
+ m_tb_prefs.removeObserver("mathml", this);
+ m_tb_prefs.removeObserver("svg", this);
var observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
@@ -281,9 +274,6 @@ function torbutton_init() {
}
m_tb_wasinited = true;
- m_tb_prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
-
// Determine if we are running inside Tor Browser.
var cur_version;
try {
@@ -1342,9 +1332,7 @@ function torbutton_do_new_identity() {
torbutton_log(3, "New Identity: Syncing prefs");
// Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
+ m_tb_prefs.savePrefFile(null);
torbutton_log(3, "New Identity: Clearing permissions");
@@ -1750,9 +1738,7 @@ function torbutton_update_disk_prefs() {
} catch (e) {}
// Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
+ m_tb_prefs.savePrefFile(null);
}
function torbutton_update_fingerprinting_prefs() {
@@ -1797,9 +1783,7 @@ function torbutton_update_fingerprinting_prefs() {
// XXX: How do we undo timezone?
// Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
+ m_tb_prefs.savePrefFile(null);
}
function torbutton_update_thirdparty_prefs() {
@@ -1815,9 +1799,7 @@ function torbutton_update_thirdparty_prefs() {
m_tb_prefs.setBoolPref("security.enable_tls_session_tickets", !isolate);
// Force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
+ m_tb_prefs.savePrefFile(null);
}
var torbutton_sec_ml_bool_prefs = {
1
0

[tor-browser-bundle/master] Bug 20184: OS X builds are still not reproducible
by gkï¼ torproject.org 18 Oct '16
by gkï¼ torproject.org 18 Oct '16
18 Oct '16
commit 04a9af0eb1e6466ce6a7007a46d73fb7a38442e8
Author: Georg Koppen <gk(a)torproject.org>
Date: Sun Oct 9 11:12:43 2016 +0000
Bug 20184: OS X builds are still not reproducible
We ecountered on some machines failures to reproduce OS X builds.
The investigation seems to indicate that our old toolchain plays a
crucial role in this.
This patch replaces this old toolchain with a more modern clang/cctools
for building the tor part of the bundle. Resorting to `faketime` again
was necessary to cope with inserted timestamps.
---
gitian/descriptors/mac/gitian-tor.yml | 44 +++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 15 deletions(-)
diff --git a/gitian/descriptors/mac/gitian-tor.yml b/gitian/descriptors/mac/gitian-tor.yml
index f2f4b01..ee1d848 100644
--- a/gitian/descriptors/mac/gitian-tor.yml
+++ b/gitian/descriptors/mac/gitian-tor.yml
@@ -4,19 +4,21 @@ distro: "debian"
suites:
- "wheezy"
architectures:
-- "i386"
+- "amd64"
packages:
- "unzip"
- "automake"
+- "faketime"
- "zip"
reference_datetime: "2000-01-01 00:00:00"
remotes:
- "url": "https://git.torproject.org/tor.git"
"dir": "tor"
files:
-- "versions"
+- "clang-linux64-wheezy-utils.zip"
+- "cctools.tar.gz"
- "apple-uni-sdk-10.6_20110407-0.flosoft1_i386.deb"
-- "multiarch-darwin11-cctools127.2-gcc42-5666.3-llvmgcc42-2336.1-Linux-120724.tar.xz"
+- "versions"
- "dzip.sh"
- "openssl-mac64-utils.zip"
- "libevent-mac64-utils.zip"
@@ -33,35 +35,47 @@ script: |
fi
export TZ=UTC
export LC_ALL=C
- export REFERENCE_DATETIME
+ export FAKETIME=$REFERENCE_DATETIME
umask 0022
#
mkdir -p $INSTDIR/bin/
mkdir -p $TORBINDIR/
mkdir -p $TORCONFIGDIR/
mkdir -p $OUTDIR/
- #
- # dpkg requires sbin directories in the PATH
- export PATH="/usr/sbin:/sbin:$PATH"
- sudo dpkg -i *.deb
- tar xaf multiarch-darwin*tar.xz
- export PATH="$PATH:$HOME/build/apple-osx/bin/"
+
+ # Extracting and copying all the necessary utilities and libraries. We still
+ # need the 10.6 SDK if we want to support OSX 10.6.
+ ar x apple-uni-sdk-10.6_20110407-0.flosoft1_i386.deb
+ tar xaf data.tar.gz
+ tar xaf cctools.tar.gz
+ unzip clang-linux64-wheezy-utils.zip
unzip -d $INSTDIR openssl-mac64-utils.zip
unzip -d $INSTDIR libevent-mac64-utils.zip
cp $INSTDIR/libevent/lib/libevent-*.dylib $TORBINDIR/
LIBEVENT_FILE=`basename $INSTDIR/libevent/lib/libevent-*.dylib`
+ # Setting the proper flags and variables
+ # ld needs libLTO.so from llvm
+ export LD_LIBRARY_PATH="/home/debian/build/clang/lib"
+ export PATH="/home/debian/build/cctools/bin:$PATH"
+ CROSS_CCTOOLS_PATH="/home/debian/build/cctools"
+ CROSS_SYSROOT="/home/debian/build/usr/lib/apple/SDKs/MacOSX10.6.sdk"
+ FLAGS="-target x86_64-apple-darwin10 -mlinker-version=136 -B $CROSS_CCTOOLS_PATH/bin -isysroot $CROSS_SYSROOT"
+ export CC="/home/debian/build/clang/bin/clang $FLAGS"
+ export CXX="/home/debian/build/clang/bin/clang++ $FLAGS"
+ export CPP="/home/debian/build/clang/bin/clang $FLAGS -E"
+ export LLVMCONFIG="/home/debian/build/clang/bin/llvm-config"
+ export LDFLAGS="-Wl,-syslibroot,$CROSS_SYSROOT -Wl,-dead_strip"
+
# Building tor
- # XXX Clean up these flags?
- export CFLAGS="-m64 -I${INSTDIR}/openssl/include -I/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/include/ -I/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/ -I. -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/ -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/system/ -mmacosx-version-min=10.5"
- export LDFLAGS="-m64 -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/ -L/usr/lib/apple/SDKs/MacOSX10.6.sdk/usr/lib/system/ -mmacosx-version-min=10.5"
cd tor
git update-index --refresh -q
mkdir -p $OUTDIR/src
#git archive HEAD | tar -x -C $OUTDIR/src
./autogen.sh
find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
- ./configure --enable-static-openssl --disable-asciidoc --host=i686-apple-darwin11 --with-libevent-dir=$INSTDIR/libevent --with-openssl-dir=$INSTDIR/openssl --prefix=$INSTDIR
+ ./configure --enable-static-openssl --disable-asciidoc --host=x86_64-apple-darwin10 --with-libevent-dir=$INSTDIR/libevent --with-openssl-dir=$INSTDIR/openssl --prefix=$INSTDIR
+ export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
make $MAKEOPTS
make install
cd $INSTDIR
@@ -69,7 +83,7 @@ script: |
cp share/tor/geoip $TORCONFIGDIR/
cp share/tor/geoip6 $TORCONFIGDIR/
cd $TORBINDIR/
- i686-apple-darwin11-install_name_tool -change $INSTDIR/libevent/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
+ x86_64-apple-darwin10-install_name_tool -change $INSTDIR/libevent/lib/$LIBEVENT_FILE @executable_path/$LIBEVENT_FILE tor
# Grabbing the result
cd $INSTDIR
1
0

17 Oct '16
commit 7a0efdf6a99969007792d418a6bbfd5e0da4b3cf
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Thu Oct 6 21:58:50 2016 -0700
Bug 18093: Remove 'Restore Defaults' button
---
src/chrome/content/preferences.js | 57 ------------------------------------
src/chrome/content/preferences.xul | 4 +--
src/chrome/content/torbutton_util.js | 24 ---------------
src/chrome/locale/en/torbutton.dtd | 1 -
4 files changed, 1 insertion(+), 85 deletions(-)
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 28f5955..1d85cde 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -54,63 +54,6 @@ function torbutton_prefs_save(doc) {
}
}
-function torbutton_prefs_reset_defaults() {
- var o_torprefs = torbutton_get_prefbranch('extensions.torbutton.');
- var tmpcnt = new Object();
- var children;
- var i;
- var loglevel = o_torprefs.getIntPref("loglevel");
- var logmthd = o_torprefs.getIntPref("logmethod");
-
- torbutton_log(3, "Starting Pref reset");
-
- // 1. Clear torbutton settings
- // 2. Clear browser proxy settings
- // 3. Reset Security Slider settings
-
- // XXX Warning: The only reason this works is because of Firefox's
- // threading model. As soon as a pref is changed, all observers
- // are notified by that same thread, immediately. Since torbutton's
- // security state is driven by proxy pref observers, this
- // causes everything to be reset in a linear order. If firefox
- // ever makes pref observers asynchonous, this will all break.
-
- children = o_torprefs.getChildList("" , tmpcnt);
- for(i = 0; i < children.length; i++) {
- if(o_torprefs.prefHasUserValue(children[i]))
- o_torprefs.clearUserPref(children[i]);
- }
-
- // Keep logging the same.
- o_torprefs.setIntPref("loglevel", loglevel);
- o_torprefs.setIntPref("logmethod", logmthd);
-
- torbutton_log(3, "Resetting browser prefs");
-
- // Reset browser prefs that torbutton touches just in case
- // they get horked. Better everything gets set back to default
- // than some arcane pref gets wedged with no clear way to fix it.
- // Technical users who tuned these by themselves will be able to fix it.
- // It's the non-technical ones we should make it easy for
- torbutton_reset_browser_prefs();
-
- // Resetting the Security Slider preferences
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- var win = wm.getMostRecentWindow("navigator:browser");
- o_torprefs.setBoolPref('security_custom', false);
- o_torprefs.setIntPref('security_slider', 4);
- win.torbutton_update_security_slider();
-
- torbutton_log(4, "Preferences reset to defaults");
- torbutton_prefs_init(window.document);
-
- // In all cases, force prefs to be synced to disk
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefService.savePrefFile(null);
-}
-
function torbutton_toggle_slider(doc, pos) {
doc.getElementById("torbutton_sec_slider").value = pos;
// Make sure the custom checkbox is unchecked as the user seems to want one
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index 62f649f..574932e 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -8,9 +8,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="&torbutton.prefs.security_settings;"
- buttons="accept,cancel,extra1"
- buttonlabelextra1="&torbutton.prefs.restore_defaults;"
- ondialogextra1="torbutton_prefs_reset_defaults();"
+ buttons="accept,cancel"
persist="screenX screenY width height"
onload="torbutton_prefs_init(document)"
align="stretch"
diff --git a/src/chrome/content/torbutton_util.js b/src/chrome/content/torbutton_util.js
index 1558ced..f1263f1 100644
--- a/src/chrome/content/torbutton_util.js
+++ b/src/chrome/content/torbutton_util.js
@@ -52,30 +52,6 @@ function torbutton_get_prefbranch(branch_name) {
return o_branch;
}
-// Bug 1506 P3: This would be a semi-polite thing to do on uninstall
-// for pure Firefox users. The most polite thing would be to save
-// all their original prefs.. But meh?
-function torbutton_reset_browser_prefs() {
- var o_all_prefs = torbutton_get_prefbranch('');
- var prefs = ["network.http.sendSecureXSiteReferrer",
- "network.http.sendRefererHeader", "dom.storage.enabled",
- "extensions.update.enabled", "app.update.enabled",
- "app.update.auto", "browser.search.update",
- "browser.cache.memory.enable", "network.http.use-cache",
- "browser.cache.disk.enable", "browser.safebrowsing.enabled",
- "browser.send_pings", "browser.safebrowsing.remoteLookups",
- "network.security.ports.banned", "browser.search.suggest.enabled",
- "security.enable_java", "browser.history_expire_days",
- "browser.download.manager.retention", "browser.formfill.enable",
- "signon.rememberSignons", "plugin.disable_full_page_plugin_for_types",
- "browser.bookmarks.livemark_refresh_seconds",
- "network.cookie.lifetimePolicy" ];
- for(var i = 0; i < prefs.length; i++) {
- if(o_all_prefs.prefHasUserValue(prefs[i]))
- o_all_prefs.clearUserPref(prefs[i]);
- }
-}
-
// load localization strings
function torbutton_get_stringbundle()
{
diff --git a/src/chrome/locale/en/torbutton.dtd b/src/chrome/locale/en/torbutton.dtd
index 0ea18e5..56f663e 100644
--- a/src/chrome/locale/en/torbutton.dtd
+++ b/src/chrome/locale/en/torbutton.dtd
@@ -12,7 +12,6 @@
<!ENTITY torbutton.context_menu.cookieProtections.key "C">
<!ENTITY torbutton.button.tooltip "Click to initialize Torbutton">
<!ENTITY torbutton.prefs.security_settings "Security Settings">
-<!ENTITY torbutton.prefs.restore_defaults "Restore Defaults">
<!ENTITY torbutton.cookiedialog.title "Manage Cookie Protections">
<!ENTITY torbutton.cookiedialog.lockCol "Protected">
<!ENTITY torbutton.cookiedialog.domainCol "Host">
1
0

[tor-browser-bundle/master] Revert "Bug 13893: Make Tor Browser compatible with EMET"
by gkï¼ torproject.org 17 Oct '16
by gkï¼ torproject.org 17 Oct '16
17 Oct '16
commit 48b0c33bf651baaaa972e81490b3896dd332437e
Author: Georg Koppen <gk(a)torproject.org>
Date: Mon Oct 17 11:52:19 2016 +0000
Revert "Bug 13893: Make Tor Browser compatible with EMET"
This reverts commit 0348263efd1cb8a9eca8737f3dc7734ef75e0966.
Firefox is not ready for GCC 6 yet. See #20381 for further details.
---
gitian/descriptors/windows/gitian-utils.yml | 7 -
gitian/patches/gcc_62_1.patch | 23 -
gitian/patches/gcc_62_2.patch | 1198 ---------------------------
gitian/versions.alpha | 6 +-
gitian/versions.nightly | 6 +-
5 files changed, 6 insertions(+), 1234 deletions(-)
diff --git a/gitian/descriptors/windows/gitian-utils.yml b/gitian/descriptors/windows/gitian-utils.yml
index d3598e2..9c31834 100644
--- a/gitian/descriptors/windows/gitian-utils.yml
+++ b/gitian/descriptors/windows/gitian-utils.yml
@@ -35,8 +35,6 @@ files:
- "nsis.tar.bz2"
- "nsis-debian.tar.xz"
- "nsis-missing-unistd-include.patch"
-- "gcc_62_1.patch"
-- "gcc_62_2.patch"
script: |
INSTDIR="$HOME/install"
source versions
@@ -81,11 +79,6 @@ script: |
mkdir gcc
cd gcc
tar -xjvf ../gcc.tar.bz2
- cd gcc-*
- # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459.
- patch -p1 < ~/build/gcc_62_1.patch
- patch -p1 < ~/build/gcc_62_2.patch
- cd ..
# We don't want to link against msvcrt.dll due to bug 9084.
i686-w64-mingw32-g++ -dumpspecs > ~/build/msvcr100.spec
sed 's/msvcrt/msvcr100/' -i ~/build/msvcr100.spec
diff --git a/gitian/patches/gcc_62_1.patch b/gitian/patches/gcc_62_1.patch
deleted file mode 100644
index 7ca36d8..0000000
--- a/gitian/patches/gcc_62_1.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 1ec6206ea80ceb5df843ea0bc4ef04d9ab17257e Mon Sep 17 00:00:00 2001
-From: Georg Koppen <gk(a)torproject.org>
-Date: Wed, 14 Sep 2016 12:53:19 +0000
-Subject: [PATCH 1/2] Revert "2015-09-17 Catherine Moore
- <clm(a)codesourcery.com>"
-
-This reverts commit a63a17505346bb3a91ce3de6fe238264c4d849ac.
-
-diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
-index f25304c..308802e 100644
---- a/libstdc++-v3/src/c++11/debug.cc
-+++ b/libstdc++-v3/src/c++11/debug.cc
-@@ -32,7 +32,6 @@
- #include <debug/safe_local_iterator.h>
-
- #include <cassert>
--#include <cstdio>
-
- #include <algorithm> // for std::min
- #include <functional> // for _Hash_impl
---
-2.9.3
-
diff --git a/gitian/patches/gcc_62_2.patch b/gitian/patches/gcc_62_2.patch
deleted file mode 100644
index 7dbd826..0000000
--- a/gitian/patches/gcc_62_2.patch
+++ /dev/null
@@ -1,1198 +0,0 @@
-From 0fbc32fdb5e0119877b0fd608d8855af0e4e376e Mon Sep 17 00:00:00 2001
-From: Georg Koppen <gk(a)torproject.org>
-Date: Wed, 14 Sep 2016 12:54:30 +0000
-Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"2015-09-17=20=20Fran=C3=A7ois=20D?=
- =?UTF-8?q?umont=20=20<fdumont(a)gcc.gnu.org>"?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This reverts commit 426075db14da88357dd104345b5edea369f1d5c6.
-
-diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h
-index 72db612..7d4f027 100644
---- a/libstdc++-v3/include/debug/formatter.h
-+++ b/libstdc++-v3/include/debug/formatter.h
-@@ -132,13 +132,6 @@ namespace __gnu_debug
-
- class _Error_formatter
- {
-- // Tags denoting the type of parameter for construction
-- struct _Is_iterator { };
-- struct _Is_iterator_value_type { };
-- struct _Is_sequence { };
-- struct _Is_instance { };
--
-- public:
- /// Whether an iterator is constant, mutable, or unknown
- enum _Constness
- {
-@@ -160,6 +153,13 @@ namespace __gnu_debug
- __last_state
- };
-
-+ // Tags denoting the type of parameter for construction
-+ struct _Is_iterator { };
-+ struct _Is_iterator_value_type { };
-+ struct _Is_sequence { };
-+ struct _Is_instance { };
-+
-+ public:
- // A parameter that may be referenced by an error message
- struct _Parameter
- {
-@@ -375,16 +375,15 @@ namespace __gnu_debug
-
- void
- _M_print_field(const _Error_formatter* __formatter,
-- const char* __name) const _GLIBCXX_DEPRECATED;
-+ const char* __name) const;
-
- void
-- _M_print_description(const _Error_formatter* __formatter)
-- const _GLIBCXX_DEPRECATED;
-+ _M_print_description(const _Error_formatter* __formatter) const;
- };
-
- template<typename _Iterator>
-- _Error_formatter&
-- _M_iterator(const _Iterator& __it, const char* __name = 0)
-+ const _Error_formatter&
-+ _M_iterator(const _Iterator& __it, const char* __name = 0) const
- {
- if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] = _Parameter(__it, __name,
-@@ -393,59 +392,57 @@ namespace __gnu_debug
- }
-
- template<typename _Iterator>
-- _Error_formatter&
-+ const _Error_formatter&
- _M_iterator_value_type(const _Iterator& __it,
-- const char* __name = 0)
-+ const char* __name = 0) const
- {
-- if (_M_num_parameters < __max_parameters)
-+ if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] =
- _Parameter(__it, __name, _Is_iterator_value_type());
- return *this;
- }
-
-- _Error_formatter&
-- _M_integer(long __value, const char* __name = 0)
-+ const _Error_formatter&
-+ _M_integer(long __value, const char* __name = 0) const
- {
-- if (_M_num_parameters < __max_parameters)
-+ if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
- return *this;
- }
-
-- _Error_formatter&
-- _M_string(const char* __value, const char* __name = 0)
-+ const _Error_formatter&
-+ _M_string(const char* __value, const char* __name = 0) const
- {
-- if (_M_num_parameters < __max_parameters)
-+ if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] = _Parameter(__value, __name);
- return *this;
- }
-
- template<typename _Sequence>
-- _Error_formatter&
-- _M_sequence(const _Sequence& __seq, const char* __name = 0)
-+ const _Error_formatter&
-+ _M_sequence(const _Sequence& __seq, const char* __name = 0) const
- {
-- if (_M_num_parameters < __max_parameters)
-+ if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name,
- _Is_sequence());
- return *this;
- }
-
- template<typename _Type>
-- _Error_formatter&
-- _M_instance(const _Type& __inst, const char* __name = 0)
-+ const _Error_formatter&
-+ _M_instance(const _Type& __inst, const char* __name = 0) const
- {
-- if (_M_num_parameters < __max_parameters)
-+ if (_M_num_parameters < std::size_t(__max_parameters))
- _M_parameters[_M_num_parameters++] = _Parameter(__inst, __name,
- _Is_instance());
- return *this;
- }
-
-- _Error_formatter&
-- _M_message(const char* __text)
-+ const _Error_formatter&
-+ _M_message(const char* __text) const
- { _M_text = __text; return *this; }
-
-- // Kept const qualifier for backward compatibility, to keep the same
-- // exported symbol.
-- _Error_formatter&
-+ const _Error_formatter&
- _M_message(_Debug_msg_id __id) const throw ();
-
- _GLIBCXX_NORETURN void
-@@ -453,38 +450,40 @@ namespace __gnu_debug
-
- template<typename _Tp>
- void
-- _M_format_word(char*, int, const char*, _Tp)
-- const throw () _GLIBCXX_DEPRECATED;
-+ _M_format_word(char*, int, const char*, _Tp) const throw ();
-
- void
-- _M_print_word(const char* __word) const _GLIBCXX_DEPRECATED;
-+ _M_print_word(const char* __word) const;
-
- void
-- _M_print_string(const char* __string) const _GLIBCXX_DEPRECATED;
-+ _M_print_string(const char* __string) const;
-
- private:
-- _Error_formatter(const char* __file, unsigned int __line)
-- : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0)
-- { }
-+ _Error_formatter(const char* __file, std::size_t __line)
-+ : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0),
-+ _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
-+ { _M_get_max_length(); }
-
- void
-- _M_get_max_length() const throw () _GLIBCXX_DEPRECATED;
-+ _M_get_max_length() const throw ();
-
- enum { __max_parameters = 9 };
-
- const char* _M_file;
-- unsigned int _M_line;
-- _Parameter _M_parameters[__max_parameters];
-- unsigned int _M_num_parameters;
-- const char* _M_text;
-+ std::size_t _M_line;
-+ mutable _Parameter _M_parameters[__max_parameters];
-+ mutable std::size_t _M_num_parameters;
-+ mutable const char* _M_text;
-+ mutable std::size_t _M_max_length;
-+ enum { _M_indent = 4 } ;
-+ mutable std::size_t _M_column;
-+ mutable bool _M_first_line;
-+ mutable bool _M_wordwrap;
-
- public:
-- static _Error_formatter&
-- _M_at(const char* __file, unsigned int __line)
-- {
-- static _Error_formatter __formatter(__file, __line);
-- return __formatter;
-- }
-+ static _Error_formatter
-+ _M_at(const char* __file, std::size_t __line)
-+ { return _Error_formatter(__file, __line); }
- };
- } // namespace __gnu_debug
-
-diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
-index 308802e..8f7eaa3 100644
---- a/libstdc++-v3/src/c++11/debug.cc
-+++ b/libstdc++-v3/src/c++11/debug.cc
-@@ -22,19 +22,18 @@
- // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
- // <http://www.gnu.org/licenses/>.
-
--#include <bits/move.h>
--#include <bits/stl_iterator_base_types.h>
--
--#include <debug/formatter.h>
-+#include <debug/debug.h>
- #include <debug/safe_base.h>
- #include <debug/safe_unordered_base.h>
- #include <debug/safe_iterator.h>
- #include <debug/safe_local_iterator.h>
--
-+#include <algorithm>
- #include <cassert>
--
--#include <algorithm> // for std::min
--#include <functional> // for _Hash_impl
-+#include <cstring>
-+#include <cctype>
-+#include <cstdio>
-+#include <cstdlib>
-+#include <functional>
-
- #include <cxxabi.h> // for __cxa_demangle
-
-@@ -525,123 +524,37 @@ namespace __gnu_debug
-
- namespace
- {
-- using _Error_formatter = __gnu_debug::_Error_formatter;
-- using _Parameter = __gnu_debug::_Error_formatter::_Parameter;
--
-- template<typename _Tp>
-- int
-- format_word(char* buf, int n, const char* fmt, _Tp s)
-- { return std::min(__builtin_snprintf(buf, n, fmt, s), n - 1); }
--
-- void
-- get_max_length(std::size_t& max_length)
-- {
-- const char* nptr = std::getenv("GLIBCXX_DEBUG_MESSAGE_LENGTH");
-- if (nptr)
-- {
-- char* endptr;
-- const unsigned long ret = std::strtoul(nptr, &endptr, 0);
-- if (*nptr != '\0' && *endptr == '\0')
-- max_length = ret;
-- }
-- }
--
-- struct PrintContext
-- {
-- PrintContext()
-- : _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
-- { get_max_length(_M_max_length); }
--
-- std::size_t _M_max_length;
-- enum { _M_indent = 4 } ;
-- std::size_t _M_column;
-- bool _M_first_line;
-- bool _M_wordwrap;
-- };
--
-- void
-- print_word(PrintContext& ctx, const char* word,
-- std::ptrdiff_t count = -1)
-- {
-- size_t length = count >= 0 ? count : __builtin_strlen(word);
-- if (length == 0)
-- return;
--
-- // Consider first '\n' at begining cause it impacts column.
-- if (word[0] == '\n')
-- {
-- fprintf(stderr, "\n");
-- ctx._M_column = 1;
-- ++word;
-- --length;
--
-- if (length == 0)
-- return;
-- }
--
-- size_t visual_length
-- = isspace(word[length - 1]) ? length - 1 : length;
-- if (visual_length == 0
-- || !ctx._M_wordwrap
-- || (ctx._M_column + visual_length < ctx._M_max_length)
-- || (visual_length >= ctx._M_max_length && ctx._M_column == 1))
-- {
-- // If this isn't the first line, indent
-- if (ctx._M_column == 1 && !ctx._M_first_line)
-- {
-- char spacing[ctx._M_indent + 1];
-- for (int i = 0; i < ctx._M_indent; ++i)
-- spacing[i] = ' ';
-- spacing[ctx._M_indent] = '\0';
-- fprintf(stderr, "%s", spacing);
-- ctx._M_column += ctx._M_indent;
-- }
--
-- int written = fprintf(stderr, "%s", word);
--
-- if (word[length - 1] == '\n')
-- {
-- ctx._M_first_line = false;
-- ctx._M_column = 1;
-- }
-- else
-- ctx._M_column += written;
-- }
-- else
-- {
-- print_word(ctx, "\n", 1);
-- print_word(ctx, word, count);
-- }
-- }
--
- void
-- print_type(PrintContext& ctx,
-- const type_info* info,
-- const char* unknown_name)
-+ print_type(const __gnu_debug::_Error_formatter* __formatter,
-+ const type_info* __info,
-+ const char* __unknown_name)
- {
-- if (!info)
-- print_word(ctx, unknown_name);
-+ if (!__info)
-+ __formatter->_M_print_word(__unknown_name);
- else
- {
-- int status;
-- char* demangled_name =
-- __cxxabiv1::__cxa_demangle(info->name(), NULL, NULL, &status);
-- print_word(ctx, status == 0 ? demangled_name : info->name());
-- free(demangled_name);
-+ int __status;
-+ char* __demangled_name =
-+ __cxxabiv1::__cxa_demangle(__info->name(), NULL, NULL, &__status);
-+ __formatter->_M_print_word(__status == 0
-+ ? __demangled_name : __info->name());
-+ free(__demangled_name);
- }
- }
-
- bool
-- print_field(PrintContext& ctx,
-- const char* name, const _Parameter::_Type& type)
-+ print_field(
-+ const __gnu_debug::_Error_formatter* __formatter,
-+ const char* __name,
-+ const __gnu_debug::_Error_formatter::_Parameter::_Type& __variant)
- {
-- if (__builtin_strcmp(name, "name") == 0)
-+ if (strcmp(__name, "name") == 0)
- {
-- assert(type._M_name);
-- print_word(ctx, type._M_name);
-+ assert(__variant._M_name);
-+ __formatter->_M_print_word(__variant._M_name);
- }
-- else if (__builtin_strcmp(name, "type") == 0)
-- print_type(ctx, type._M_type, "<unknown type>");
-+ else if (strcmp(__name, "type") == 0)
-+ print_type(__formatter, __variant._M_type, "<unknown type>");
- else
- return false;
-
-@@ -649,17 +562,21 @@ namespace
- }
-
- bool
-- print_field(PrintContext& ctx,
-- const char* name, const _Parameter::_Instance& inst)
-+ print_field(
-+ const __gnu_debug::_Error_formatter* __formatter,
-+ const char* __name,
-+ const __gnu_debug::_Error_formatter::_Parameter::_Instance& __variant)
- {
-- const _Parameter::_Type& type = inst;
-- if (print_field(ctx, name, type))
-+ const __gnu_debug::_Error_formatter::_Parameter::_Type& __type = __variant;
-+ if (print_field(__formatter, __name, __type))
- { }
-- else if (__builtin_strcmp(name, "address") == 0)
-+ else if (strcmp(__name, "address") == 0)
- {
-- char buf[64];
-- int ret = __builtin_sprintf(buf, "%p", inst._M_address);
-- print_word(ctx, buf, ret);
-+ const int __bufsize = 64;
-+ char __buf[__bufsize];
-+ __formatter->_M_format_word(__buf, __bufsize, "%p",
-+ __variant._M_address);
-+ __formatter->_M_print_word(__buf);
- }
- else
- return false;
-@@ -668,390 +585,278 @@ namespace
- }
-
- void
-- print_field(PrintContext& ctx, const _Parameter& param, const char* name)
-- {
-- assert(param._M_kind != _Parameter::__unused_param);
-- const int bufsize = 64;
-- char buf[bufsize];
--
-- const auto& variant = param._M_variant;
-- switch (param._M_kind)
-- {
-- case _Parameter::__iterator:
-- {
-- const auto& iterator = variant._M_iterator;
-- if (print_field(ctx, name, iterator))
-- { }
-- else if (__builtin_strcmp(name, "constness") == 0)
-- {
-- static const char*
-- constness_names[_Error_formatter::__last_constness] =
-- {
-- "<unknown>",
-- "constant",
-- "mutable"
-- };
-- print_word(ctx, constness_names[iterator._M_constness]);
-- }
-- else if (__builtin_strcmp(name, "state") == 0)
-- {
-- static const char*
-- state_names[_Error_formatter::__last_state] =
-- {
-- "<unknown>",
-- "singular",
-- "dereferenceable (start-of-sequence)",
-- "dereferenceable",
-- "past-the-end",
-- "before-begin"
-- };
-- print_word(ctx, state_names[iterator._M_state]);
-- }
-- else if (__builtin_strcmp(name, "sequence") == 0)
-- {
-- assert(iterator._M_sequence);
-- int written = __builtin_sprintf(buf, "%p", iterator._M_sequence);
-- print_word(ctx, buf, written);
-- }
-- else if (__builtin_strcmp(name, "seq_type") == 0)
-- print_type(ctx, iterator._M_seq_type, "<unknown seq_type>");
-- else
-- assert(false);
-- }
-- break;
--
-- case _Parameter::__sequence:
-- if (!print_field(ctx, name, variant._M_sequence))
-- assert(false);
-- break;
--
-- case _Parameter::__integer:
-- if (__builtin_strcmp(name, "name") == 0)
-- {
-- assert(variant._M_integer._M_name);
-- print_word(ctx, variant._M_integer._M_name);
-- }
-- else
-- assert(false);
-- break;
--
-- case _Parameter::__string:
-- if (__builtin_strcmp(name, "name") == 0)
-- {
-- assert(variant._M_string._M_name);
-- print_word(ctx, variant._M_string._M_name);
-- }
-- else
-- assert(false);
-- break;
--
-- case _Parameter::__instance:
-- if (!print_field(ctx, name, variant._M_instance))
-- assert(false);
-- break;
--
-- case _Parameter::__iterator_value_type:
-- if (!print_field(ctx, name, variant._M_iterator_value_type))
-- assert(false);
-- break;
--
-- default:
-- assert(false);
-- break;
-- }
-- }
--
-- void
-- print_description(PrintContext& ctx, const _Parameter::_Type& type)
-+ print_description(
-+ const __gnu_debug::_Error_formatter* __formatter,
-+ const __gnu_debug::_Error_formatter::_Parameter::_Type& __variant)
- {
-- if (type._M_name)
-+ if (__variant._M_name)
- {
-- const int bufsize = 64;
-- char buf[bufsize];
-- int written
-- = format_word(buf, bufsize, "\"%s\"", type._M_name);
-- print_word(ctx, buf, written);
-+ const int __bufsize = 64;
-+ char __buf[__bufsize];
-+ __formatter->_M_format_word(__buf, __bufsize, "\"%s\"",
-+ __variant._M_name);
-+ __formatter->_M_print_word(__buf);
- }
-
-- print_word(ctx, " {\n");
-+ __formatter->_M_print_word(" {\n");
-
-- if (type._M_type)
-+ if (__variant._M_type)
- {
-- print_word(ctx, " type = ");
-- print_type(ctx, type._M_type, "<unknown type>");
-- print_word(ctx, ";\n");
-+ __formatter->_M_print_word(" type = ");
-+ print_type(__formatter, __variant._M_type, "<unknown type>");
-+ __formatter->_M_print_word(";\n");
- }
- }
-
-+
- void
-- print_description(PrintContext& ctx, const _Parameter::_Instance& inst)
-+ print_description(
-+ const __gnu_debug::_Error_formatter* __formatter,
-+ const __gnu_debug::_Error_formatter::_Parameter::_Instance& __variant)
- {
-- const int bufsize = 64;
-- char buf[bufsize];
-+ const int __bufsize = 64;
-+ char __buf[__bufsize];
-
-- if (inst._M_name)
-+ if (__variant._M_name)
- {
-- int written
-- = format_word(buf, bufsize, "\"%s\" ", inst._M_name);
-- print_word(ctx, buf, written);
-+ __formatter->_M_format_word(__buf, __bufsize, "\"%s\" ",
-+ __variant._M_name);
-+ __formatter->_M_print_word(__buf);
- }
-
-- int written
-- = __builtin_sprintf(buf, "@ 0x%p {\n", inst._M_address);
-- print_word(ctx, buf, written);
-+ __formatter->_M_format_word(__buf, __bufsize, "@ 0x%p {\n",
-+ __variant._M_address);
-+ __formatter->_M_print_word(__buf);
-
-- if (inst._M_type)
-+ if (__variant._M_type)
- {
-- print_word(ctx, " type = ");
-- print_type(ctx, inst._M_type, "<unknown type>");
-+ __formatter->_M_print_word(" type = ");
-+ print_type(__formatter, __variant._M_type, "<unknown type>");
- }
- }
-+}
-
-+namespace __gnu_debug
-+{
- void
-- print_description(PrintContext& ctx, const _Parameter& param)
-+ _Error_formatter::_Parameter::
-+ _M_print_field(const _Error_formatter* __formatter, const char* __name) const
- {
-- const int bufsize = 128;
-- char buf[bufsize];
-+ assert(this->_M_kind != _Parameter::__unused_param);
-+ const int __bufsize = 64;
-+ char __buf[__bufsize];
-
-- const auto& variant = param._M_variant;
-- switch (param._M_kind)
-- {
-- case _Parameter::__iterator:
-+ switch (_M_kind)
-+ {
-+ case __iterator:
-+ if (print_field(__formatter, __name, _M_variant._M_iterator))
-+ { }
-+ else if (strcmp(__name, "constness") == 0)
- {
-- const auto& ite = variant._M_iterator;
--
-- print_word(ctx, "iterator ");
-- print_description(ctx, ite);
--
-- if (ite._M_type)
-- {
-- if (ite._M_constness != _Error_formatter::__unknown_constness)
-- {
-- print_word(ctx, " (");
-- print_field(ctx, param, "constness");
-- print_word(ctx, " iterator)");
-- }
--
-- print_word(ctx, ";\n");
-- }
--
-- if (ite._M_state != _Error_formatter::__unknown_state)
-+ static const char* __constness_names[__last_constness] =
- {
-- print_word(ctx, " state = ");
-- print_field(ctx, param, "state");
-- print_word(ctx, ";\n");
-- }
--
-- if (ite._M_sequence)
-+ "<unknown>",
-+ "constant",
-+ "mutable"
-+ };
-+ __formatter->_M_print_word(__constness_names[_M_variant.
-+ _M_iterator.
-+ _M_constness]);
-+ }
-+ else if (strcmp(__name, "state") == 0)
-+ {
-+ static const char* __state_names[__last_state] =
- {
-- print_word(ctx, " references sequence ");
-- if (ite._M_seq_type)
-- {
-- print_word(ctx, "with type '");
-- print_field(ctx, param, "seq_type");
-- print_word(ctx, "' ");
-- }
--
-- int written
-- = __builtin_sprintf(buf, "@ 0x%p\n", ite._M_sequence);
-- print_word(ctx, buf, written);
-- }
--
-- print_word(ctx, "}\n", 2);
-+ "<unknown>",
-+ "singular",
-+ "dereferenceable (start-of-sequence)",
-+ "dereferenceable",
-+ "past-the-end",
-+ "before-begin"
-+ };
-+ __formatter->_M_print_word(__state_names[_M_variant.
-+ _M_iterator._M_state]);
- }
-- break;
--
-- case _Parameter::__sequence:
-- print_word(ctx, "sequence ");
-- print_description(ctx, variant._M_sequence);
--
-- if (variant._M_sequence._M_type)
-- print_word(ctx, ";\n", 2);
--
-- print_word(ctx, "}\n", 2);
-- break;
--
-- case _Parameter::__instance:
-- print_word(ctx, "instance ");
-- print_description(ctx, variant._M_instance);
--
-- if (variant._M_instance._M_type)
-- print_word(ctx, ";\n", 2);
--
-- print_word(ctx, "}\n", 2);
-- break;
--
-- case _Parameter::__iterator_value_type:
-- print_word(ctx, "iterator::value_type ");
-- print_description(ctx, variant._M_iterator_value_type);
-- print_word(ctx, "}\n", 2);
-- break;
--
-- default:
-- break;
-- }
-+ else if (strcmp(__name, "sequence") == 0)
-+ {
-+ assert(_M_variant._M_iterator._M_sequence);
-+ __formatter->_M_format_word(__buf, __bufsize, "%p",
-+ _M_variant._M_iterator._M_sequence);
-+ __formatter->_M_print_word(__buf);
-+ }
-+ else if (strcmp(__name, "seq_type") == 0)
-+ print_type(__formatter, _M_variant._M_iterator._M_seq_type,
-+ "<unknown seq_type>");
-+ else
-+ assert(false);
-+ break;
-+ case __sequence:
-+ if (!print_field(__formatter, __name, _M_variant._M_sequence))
-+ assert(false);
-+ break;
-+ case __integer:
-+ if (strcmp(__name, "name") == 0)
-+ {
-+ assert(_M_variant._M_integer._M_name);
-+ __formatter->_M_print_word(_M_variant._M_integer._M_name);
-+ }
-+ else
-+ assert(false);
-+ break;
-+ case __string:
-+ if (strcmp(__name, "name") == 0)
-+ {
-+ assert(_M_variant._M_string._M_name);
-+ __formatter->_M_print_word(_M_variant._M_string._M_name);
-+ }
-+ else
-+ assert(false);
-+ break;
-+ case __instance:
-+ if (!print_field(__formatter, __name, _M_variant._M_instance))
-+ assert(false);
-+ break;
-+ case __iterator_value_type:
-+ if (!print_field(__formatter, __name, _M_variant._M_iterator_value_type))
-+ assert(false);
-+ break;
-+ default:
-+ assert(false);
-+ break;
-+ }
- }
-
- void
-- print_string(PrintContext& ctx, const char* string,
-- const _Parameter* parameters, std::size_t num_parameters)
-+ _Error_formatter::_Parameter::
-+ _M_print_description(const _Error_formatter* __formatter) const
- {
-- const char* start = string;
-- const int bufsize = 128;
-- char buf[bufsize];
-- int bufindex = 0;
-+ const int __bufsize = 128;
-+ char __buf[__bufsize];
-
-- while (*start)
-+ switch (_M_kind)
- {
-- if (isspace(*start))
-- {
-- buf[bufindex++] = *start++;
-- buf[bufindex] = '\0';
-- print_word(ctx, buf, bufindex);
-- bufindex = 0;
-- continue;
-- }
-+ case __iterator:
-+ __formatter->_M_print_word("iterator ");
-+ print_description(__formatter, _M_variant._M_iterator);
-
-- if (*start != '%')
-+ if (_M_variant._M_iterator._M_type)
- {
-- // Normal char.
-- buf[bufindex++] = *start++;
-- continue;
-- }
--
-- if (*++start == '%')
-- {
-- // Escaped '%'
-- buf[bufindex++] = *start++;
-- continue;
-+ if (_M_variant._M_iterator._M_constness != __unknown_constness)
-+ {
-+ __formatter->_M_print_word(" (");
-+ _M_print_field(__formatter, "constness");
-+ __formatter->_M_print_word(" iterator)");
-+ }
-+ __formatter->_M_print_word(";\n");
- }
-
-- // We are on a parameter property reference, we need to flush buffer
-- // first.
-- if (bufindex != 0)
-+ if (_M_variant._M_iterator._M_state != __unknown_state)
- {
-- buf[bufindex] = '\0';
-- print_word(ctx, buf, bufindex);
-- bufindex = 0;
-+ __formatter->_M_print_word(" state = ");
-+ _M_print_field(__formatter, "state");
-+ __formatter->_M_print_word(";\n");
- }
-
-- // Get the parameter number
-- assert(*start >= '1' && *start <= '9');
-- size_t param_index = *start - '0' - 1;
-- assert(param_index < num_parameters);
-- const auto& param = parameters[param_index];
--
-- // '.' separates the parameter number from the field
-- // name, if there is one.
-- ++start;
-- if (*start != '.')
-+ if (_M_variant._M_iterator._M_sequence)
- {
-- assert(*start == ';');
-- ++start;
-- if (param._M_kind == _Parameter::__integer)
-+ __formatter->_M_print_word(" references sequence ");
-+ if (_M_variant._M_iterator._M_seq_type)
- {
-- int written
-- = __builtin_sprintf(buf, "%ld",
-- param._M_variant._M_integer._M_value);
-- print_word(ctx, buf, written);
-+ __formatter->_M_print_word("with type `");
-+ _M_print_field(__formatter, "seq_type");
-+ __formatter->_M_print_word("' ");
- }
-- else if (param._M_kind == _Parameter::__string)
-- print_string(ctx, param._M_variant._M_string._M_value,
-- parameters, num_parameters);
-- continue;
-- }
-
-- // Extract the field name we want
-- const int max_field_len = 16;
-- char field[max_field_len];
-- int field_idx = 0;
-- ++start;
-- while (*start != ';')
-- {
-- assert(*start);
-- assert(field_idx < max_field_len - 1);
-- field[field_idx++] = *start++;
-+ __formatter->_M_format_word(__buf, __bufsize, "@ 0x%p\n",
-+ _M_variant._M_iterator._M_sequence);
-+ __formatter->_M_print_word(__buf);
- }
-- ++start;
-- field[field_idx] = '\0';
-
-- print_field(ctx, param, field);
-- }
-+ __formatter->_M_print_word("}\n");
-+ break;
-+ case __sequence:
-+ __formatter->_M_print_word("sequence ");
-+ print_description(__formatter, _M_variant._M_sequence);
-
-- // Might need to flush.
-- if (bufindex)
-- {
-- buf[bufindex] = '\0';
-- print_word(ctx, buf, bufindex);
-+ if (_M_variant._M_sequence._M_type)
-+ __formatter->_M_print_word(";\n");
-+
-+ __formatter->_M_print_word("}\n");
-+ break;
-+ case __instance:
-+ __formatter->_M_print_word("instance ");
-+ print_description(__formatter, _M_variant._M_instance);
-+
-+ if (_M_variant._M_instance._M_type)
-+ __formatter->_M_print_word(";\n");
-+
-+ __formatter->_M_print_word("}\n");
-+ break;
-+ case __iterator_value_type:
-+ __formatter->_M_print_word("iterator::value_type ");
-+ print_description(__formatter, _M_variant._M_iterator_value_type);
-+ __formatter->_M_print_word("}\n");
-+ break;
-+ default:
-+ break;
- }
- }
--}
-
--namespace __gnu_debug
--{
-- _Error_formatter&
-+ const _Error_formatter&
- _Error_formatter::_M_message(_Debug_msg_id __id) const throw ()
-- {
-- return const_cast<_Error_formatter*>(this)
-- ->_M_message(_S_debug_messages[__id]);
-- }
-+ { return this->_M_message(_S_debug_messages[__id]); }
-
- void
- _Error_formatter::_M_error() const
- {
-- const int bufsize = 128;
-- char buf[bufsize];
-+ const int __bufsize = 128;
-+ char __buf[__bufsize];
-
- // Emit file & line number information
-- bool go_to_next_line = false;
-- PrintContext ctx;
-+ _M_column = 1;
-+ _M_wordwrap = false;
- if (_M_file)
- {
-- int written = format_word(buf, bufsize, "%s:", _M_file);
-- print_word(ctx, buf, written);
-- go_to_next_line = true;
-+ _M_format_word(__buf, __bufsize, "%s:", _M_file);
-+ _M_print_word(__buf);
-+ _M_column += strlen(__buf);
- }
-
- if (_M_line > 0)
- {
-- int written = __builtin_sprintf(buf, "%u:", _M_line);
-- print_word(ctx, buf, written);
-- go_to_next_line = true;
-+ _M_format_word(__buf, __bufsize, "%u:", _M_line);
-+ _M_print_word(__buf);
-+ _M_column += strlen(__buf);
- }
-
-- if (go_to_next_line)
-- print_word(ctx, "\n", 1);
--
-- if (ctx._M_max_length)
-- ctx._M_wordwrap = true;
--
-- print_word(ctx, "Error: ");
-+ if (_M_max_length)
-+ _M_wordwrap = true;
-+ _M_print_word("error: ");
-
- // Print the error message
- assert(_M_text);
-- print_string(ctx, _M_text, _M_parameters, _M_num_parameters);
-- print_word(ctx, ".\n", 2);
-+ _M_print_string(_M_text);
-+ _M_print_word(".\n");
-
- // Emit descriptions of the objects involved in the operation
-- ctx._M_first_line = true;
-- ctx._M_wordwrap = false;
-- bool has_header = false;
-- for (unsigned int i = 0; i < _M_num_parameters; ++i)
-+ _M_wordwrap = false;
-+ bool __has_noninteger_parameters = false;
-+ for (unsigned int __i = 0; __i < _M_num_parameters; ++__i)
- {
-- switch (_M_parameters[i]._M_kind)
-+ switch (_M_parameters[__i]._M_kind)
- {
- case _Parameter::__iterator:
- case _Parameter::__sequence:
- case _Parameter::__instance:
- case _Parameter::__iterator_value_type:
-- if (!has_header)
-+ if (!__has_noninteger_parameters)
- {
-- print_word(ctx, "\nObjects involved in the operation:\n");
-- has_header = true;
-+ _M_first_line = true;
-+ _M_print_word("\nObjects involved in the operation:\n");
-+ __has_noninteger_parameters = true;
- }
-- print_description(ctx, _M_parameters[i]);
-+ _M_parameters[__i]._M_print_description(this);
- break;
--
- default:
- break;
- }
-@@ -1060,39 +865,172 @@ namespace __gnu_debug
- abort();
- }
-
-- // Deprecated methods kept for backward compatibility.
-- void
-- _Error_formatter::_Parameter::_M_print_field(
-- const _Error_formatter*, const char*) const
-- { }
--
-- void
-- _Error_formatter::_Parameter::_M_print_description(const _Error_formatter*) const
-- { }
--
- template<typename _Tp>
- void
-- _Error_formatter::_M_format_word(char*, int, const char*, _Tp)
-- const throw ()
-- { }
-+ _Error_formatter::_M_format_word(char* __buf,
-+ int __n __attribute__ ((__unused__)),
-+ const char* __fmt, _Tp __s) const throw ()
-+ {
-+#ifdef _GLIBCXX_USE_C99
-+ std::snprintf(__buf, __n, __fmt, __s);
-+#else
-+ std::sprintf(__buf, __fmt, __s);
-+#endif
-+ }
-
- void
-- _Error_formatter::_M_print_word(const char*) const
-- { }
-+ _Error_formatter::_M_print_word(const char* __word) const
-+ {
-+ if (!_M_wordwrap)
-+ {
-+ fprintf(stderr, "%s", __word);
-+ return;
-+ }
-+
-+ size_t __length = strlen(__word);
-+ if (__length == 0)
-+ return;
-+
-+ size_t __visual_length
-+ = __word[__length - 1] == '\n' ? __length - 1 : __length;
-+ if (__visual_length == 0
-+ || (_M_column + __visual_length < _M_max_length)
-+ || (__visual_length >= _M_max_length && _M_column == 1))
-+ {
-+ // If this isn't the first line, indent
-+ if (_M_column == 1 && !_M_first_line)
-+ {
-+ char __spacing[_M_indent + 1];
-+ for (int i = 0; i < _M_indent; ++i)
-+ __spacing[i] = ' ';
-+ __spacing[_M_indent] = '\0';
-+ fprintf(stderr, "%s", __spacing);
-+ _M_column += _M_indent;
-+ }
-+
-+ fprintf(stderr, "%s", __word);
-+
-+ if (__word[__length - 1] == '\n')
-+ {
-+ _M_first_line = false;
-+ _M_column = 1;
-+ }
-+ else
-+ _M_column += __length;
-+ }
-+ else
-+ {
-+ _M_print_word("\n");
-+ _M_print_word(__word);
-+ }
-+ }
-
- void
-- _Error_formatter::_M_print_string(const char*) const
-- { }
-+ _Error_formatter::
-+ _M_print_string(const char* __string) const
-+ {
-+ const char* __start = __string;
-+ const char* __finish = __start;
-+ const int __bufsize = 128;
-+ char __buf[__bufsize];
-+
-+ while (*__start)
-+ {
-+ if (*__start != '%')
-+ {
-+ // [__start, __finish) denotes the next word
-+ __finish = __start;
-+ while (isalnum(*__finish))
-+ ++__finish;
-+ if (__start == __finish)
-+ ++__finish;
-+ if (isspace(*__finish))
-+ ++__finish;
-+
-+ const ptrdiff_t __len = __finish - __start;
-+ assert(__len < __bufsize);
-+ memcpy(__buf, __start, __len);
-+ __buf[__len] = '\0';
-+ _M_print_word(__buf);
-+ __start = __finish;
-+
-+ // Skip extra whitespace
-+ while (*__start == ' ')
-+ ++__start;
-+
-+ continue;
-+ }
-+
-+ ++__start;
-+ assert(*__start);
-+ if (*__start == '%')
-+ {
-+ _M_print_word("%");
-+ ++__start;
-+ continue;
-+ }
-+
-+ // Get the parameter number
-+ assert(*__start >= '1' && *__start <= '9');
-+ size_t __param_index = *__start - '0' - 1;
-+ assert(__param_index < _M_num_parameters);
-+ const auto& __param = _M_parameters[__param_index];
-+
-+ // '.' separates the parameter number from the field
-+ // name, if there is one.
-+ ++__start;
-+ if (*__start != '.')
-+ {
-+ assert(*__start == ';');
-+ ++__start;
-+ __buf[0] = '\0';
-+ if (__param._M_kind == _Parameter::__integer)
-+ {
-+ _M_format_word(__buf, __bufsize, "%ld",
-+ __param._M_variant._M_integer._M_value);
-+ _M_print_word(__buf);
-+ }
-+ else if (__param._M_kind == _Parameter::__string)
-+ _M_print_string(__param._M_variant._M_string._M_value);
-+ continue;
-+ }
-+
-+ // Extract the field name we want
-+ enum { __max_field_len = 16 };
-+ char __field[__max_field_len];
-+ int __field_idx = 0;
-+ ++__start;
-+ while (*__start != ';')
-+ {
-+ assert(*__start);
-+ assert(__field_idx < __max_field_len-1);
-+ __field[__field_idx++] = *__start++;
-+ }
-+ ++__start;
-+ __field[__field_idx] = 0;
-+
-+ __param._M_print_field(this, __field);
-+ }
-+ }
-
- void
- _Error_formatter::_M_get_max_length() const throw ()
-- { }
-+ {
-+ const char* __nptr = std::getenv("GLIBCXX_DEBUG_MESSAGE_LENGTH");
-+ if (__nptr)
-+ {
-+ char* __endptr;
-+ const unsigned long __ret = std::strtoul(__nptr, &__endptr, 0);
-+ if (*__nptr != '\0' && *__endptr == '\0')
-+ _M_max_length = __ret;
-+ }
-+ }
-
- // Instantiations.
- template
- void
- _Error_formatter::_M_format_word(char*, int, const char*,
-- const void*) const;
-+ const void*) const;
-
- template
- void
-@@ -1101,10 +1039,10 @@ namespace __gnu_debug
- template
- void
- _Error_formatter::_M_format_word(char*, int, const char*,
-- std::size_t) const;
-+ std::size_t) const;
-
- template
- void
- _Error_formatter::_M_format_word(char*, int, const char*,
-- const char*) const;
-+ const char*) const;
- } // namespace __gnu_debug
---
-2.9.3
-
diff --git a/gitian/versions.alpha b/gitian/versions.alpha
index f0b32d9..898e781 100755
--- a/gitian/versions.alpha
+++ b/gitian/versions.alpha
@@ -25,7 +25,7 @@ LIBEVENT_TAG=release-2.0.22-stable
CMAKE_TAG=v2.8.12.2
LLVM_TAG=8f188e0ea735ac9383a65a0d1c846eb790c2ec74 # r247539
CLANG_TAG=592b43b609b42cffd1531a700c140e10766bf049 # r247539
-MINGW_TAG=4e270fefffda8f8123c0d64b77a6855dc3c732b1 # fix Fx compilation
+MINGW_TAG=a0cd5afeb60be3be0860e9a203314c10485bb9b8
PYPTLIB_TAG=pyptlib-0.0.6
OBFSPROXY_TAG=obfsproxy-0.2.12
LIBFTE_TAG=85ef8ae58dbf0d02ea26b627e343784b5574c428 # sketch master with fix
@@ -49,7 +49,7 @@ GMP_VER=5.1.3
FIREFOX_LANG_VER=$FIREFOX_VERSION
FIREFOX_LANG_BUILD=build1
BINUTILS_VER=2.24
-GCC_VER=6.2.0
+GCC_VER=5.1.0
CLANG_VER=r247539
PYTHON_VER=2.7.5
PYCRYPTO_VER=2.6.1
@@ -117,7 +117,7 @@ GO14_HASH=9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
GO_HASH=6326aeed5f86cf18f16d6dc831405614f855e2d416a91fd3fdc334f772345b00
NSIS_HASH=43d4c9209847e35eb6e2c7cd5a7586e1445374c056c2c7899e40a080e17a1be7
NSIS_DEBIAN_HASH=1dee6957b4a4b8dfe69bcf28bc7f301a13b96b3fa5a394e36c8926ae781e774a
-GCC_HASH=9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5
+GCC_HASH=b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad
STIXMATHFONT_HASH=e3b0f712e2644438eee2d0dcd2b10b2d54f1b972039de95b2f8e800bae1adbd8
NOTOEMOJIFONT_HASH=415dc6290378574135b64c808dc640c1df7531973290c4970c51fdeb849cb0c5
NOTOJPFONT_HASH=3e8146c4ce0945f255cb9dbc12b392380af80bd117e0a60eae555c99c7e618da
diff --git a/gitian/versions.nightly b/gitian/versions.nightly
index 20c4ae4..f6dbb68 100755
--- a/gitian/versions.nightly
+++ b/gitian/versions.nightly
@@ -32,7 +32,7 @@ LIBEVENT_TAG=release-2.0.22-stable
CMAKE_TAG=v2.8.12.2
LLVM_TAG=8f188e0ea735ac9383a65a0d1c846eb790c2ec74 # r247539
CLANG_TAG=592b43b609b42cffd1531a700c140e10766bf049 # r247539
-MINGW_TAG=4e270fefffda8f8123c0d64b77a6855dc3c732b1 # fix Fx compilation
+MINGW_TAG=a0cd5afeb60be3be0860e9a203314c10485bb9b8
PYPTLIB_TAG=master
OBFSPROXY_TAG=master
LIBFTE_TAG=master
@@ -56,7 +56,7 @@ GMP_VER=5.1.3
FIREFOX_LANG_VER=$FIREFOX_VERSION
FIREFOX_LANG_BUILD=build1
BINUTILS_VER=2.24
-GCC_VER=6.2.0
+GCC_VER=5.1.0
CLANG_VER=r247539
PYTHON_VER=2.7.5
PYCRYPTO_VER=2.6.1
@@ -124,7 +124,7 @@ GO14_HASH=9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
GO_HASH=6326aeed5f86cf18f16d6dc831405614f855e2d416a91fd3fdc334f772345b00
NSIS_HASH=43d4c9209847e35eb6e2c7cd5a7586e1445374c056c2c7899e40a080e17a1be7
NSIS_DEBIAN_HASH=1dee6957b4a4b8dfe69bcf28bc7f301a13b96b3fa5a394e36c8926ae781e774a
-GCC_HASH=9944589fc722d3e66308c0ce5257788ebd7872982a718aa2516123940671b7c5
+GCC_HASH=b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad
STIXMATHFONT_HASH=e3b0f712e2644438eee2d0dcd2b10b2d54f1b972039de95b2f8e800bae1adbd8
NOTOEMOJIFONT_HASH=415dc6290378574135b64c808dc640c1df7531973290c4970c51fdeb849cb0c5
NOTOJPFONT_HASH=3e8146c4ce0945f255cb9dbc12b392380af80bd117e0a60eae555c99c7e618da
1
0

17 Oct '16
commit 52fbcbfa9df65d56dce5b1654c4d56012b3ff6a9
Author: Arthur Edelstein <arthuredelstein(a)gmail.com>
Date: Sat Oct 15 19:59:16 2016 -0700
Bug 20373: Prevent redundant dialogs opening
---
src/chrome/content/torbutton.js | 14 +++++++-------
src/modules/utils.js | 24 +++++++++++++++++++++++-
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 0f1046a..fa4009a 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -9,6 +9,7 @@
let { LoadContextInfo } = Cu.import('resource://gre/modules/LoadContextInfo.jsm');
let { Services } = Cu.import("resource://gre/modules/Services.jsm");
+let { showDialog } = Cu.import("resource://torbutton/modules/utils.js");
const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
@@ -824,9 +825,7 @@ function torbutton_on_abouttor_load(aDoc) {
label: button_label,
accessKey: 'S',
popup: null,
- callback: function() {
- window.openDialog("chrome://torbutton/content/preferences.xul",
- "torbutton-preferences","chrome");}
+ callback: torbutton_open_prefs_dialog,
}];
let priority = box.PRIORITY_INFO_LOW;
@@ -2127,14 +2126,15 @@ function torbutton_check_protections()
// Bug 1506 P2: I think cookie protections is a neat feature.
function torbutton_open_cookie_dialog() {
- window.openDialog('chrome://torbutton/content/torcookiedialog.xul','Cookie Protections',
- 'centerscreen,chrome,dialog,modal,resizable');
+ showDialog(window, 'chrome://torbutton/content/torcookiedialog.xul',
+ 'Cookie Protections', 'centerscreen,chrome,dialog,modal,resizable');
}
// Bug 1506 P2/P3: Prefs are handled differently on android, I guess?
function torbutton_open_prefs_dialog() {
- window.openDialog("chrome://torbutton/content/preferences.xul","torbutton-preferences","centerscreen, chrome");
- torbutton_log(2, 'opened preferences window');
+ showDialog(window, "chrome://torbutton/content/preferences.xul",
+ "torbutton-preferences","centerscreen, chrome");
+ torbutton_log(2, 'opened preferences window');
}
// Bug 1506 P0: Support code for checking Firefox versions. Not needed.
diff --git a/src/modules/utils.js b/src/modules/utils.js
index eb0746b..514ef51 100644
--- a/src/modules/utils.js
+++ b/src/modules/utils.js
@@ -52,5 +52,27 @@ var getEnv = function (name) {
return env.exists(name) ? env.get(name) : undefined;
};
+// ## Windows
+
+// __dialogsByName__.
+// Map of window names to dialogs.
+let dialogsByName = {};
+
+// __showDialog(parent, url, name, features, arg1, arg2, ...)__.
+// Like window.openDialog, but if the window is already
+// open, just focuses it instead of opening a new one.
+var showDialog = function (parent, url, name, features) {
+ let existingDialog = dialogsByName[name];
+ if (existingDialog && !existingDialog.closed) {
+ existingDialog.focus();
+ return existingDialog;
+ } else {
+ let newDialog = parent.openDialog.apply(parent,
+ Array.slice(arguments, 1));
+ dialogsByName[name] = newDialog;
+ return newDialog;
+ }
+};
+
// Export utility functions for external use.
-let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue", "getEnv"];
+let EXPORTED_SYMBOLS = ["bindPrefAndInit", "getPrefValue", "getEnv", "showDialog"];
1
0

[tor-browser/tor-browser-45.4.0esr-6.5-1] Bug 20304: SOCKS socket does not support spaces and other special characters
by gkï¼ torproject.org 17 Oct '16
by gkï¼ torproject.org 17 Oct '16
17 Oct '16
commit 48a73d262e04c2a90cf660445568cbcf01e83b9c
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Thu Oct 6 14:09:04 2016 -0400
Bug 20304: SOCKS socket does not support spaces and other special characters
Correctly decode file URL paths before using for them in
Unix domain socket paths.
The upstream bug is https://bugzilla.mozilla.org/show_bug.cgi?id=1308275.
---
netwerk/socket/nsSOCKSIOLayer.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp
index b26408d..be69725 100644
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -20,6 +20,8 @@
#include "nsICancelable.h"
#include "nsThreadUtils.h"
#include "nsIURL.h"
+#include "nsIFile.h"
+#include "nsNetUtil.h"
#include "mozilla/Logging.h"
#include "mozilla/net/DNS.h"
#include "mozilla/unused.h"
@@ -133,17 +135,15 @@ private:
nsresult rv;
MOZ_ASSERT(aProxyAddr);
- nsCOMPtr<nsIURL> url = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
+ nsCOMPtr<nsIFile> socketFile;
+ rv = NS_GetFileFromURLSpec(aDomainSocketPath,
+ getter_AddRefs(socketFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
- if (NS_WARN_IF(NS_FAILED(rv = url->SetSpec(aDomainSocketPath)))) {
- return rv;
- }
-
nsAutoCString path;
- if (NS_WARN_IF(NS_FAILED(rv = url->GetPath(path)))) {
+ if (NS_WARN_IF(NS_FAILED(rv = socketFile->GetNativePath(path)))) {
return rv;
}
1
0