[tor-commits] [tor/master] Merge remote-tracking branch 'public/bug25981'

2018-05-10 Thread nickm
commit 75e5b778e10cbc6caa4e4902e288a0c63f92ce06
Merge: 382beb93c 8b1380cbd
Author: Nick Mathewson 
Date:   Thu May 10 19:31:11 2018 -0400

Merge remote-tracking branch 'public/bug25981'

 src/or/main.c | 5 +
 1 file changed, 5 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Don't crash when closing a connection before initializing libevent

2018-05-10 Thread nickm
commit 8b1380cbd08f40dc2abee171a390df6d04e999d1
Author: Nick Mathewson 
Date:   Mon May 7 14:30:30 2018 -0400

Don't crash when closing a connection before initializing libevent

Fixes bug 25981; bugfix on 96c5ac338a7df.  Bug not in any released
version of Tor.
---
 src/or/main.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/or/main.c b/src/or/main.c
index c3505a2d9..87b57f89e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1676,6 +1676,11 @@ static mainloop_event_t *postloop_cleanup_ev=NULL;
 void
 mainloop_schedule_postloop_cleanup(void)
 {
+  if (PREDICT_UNLIKELY(postloop_cleanup_ev == NULL)) {
+// (It's possible that we can get here if we decide to close a connection
+// in the earliest stages of our configuration, before we create events.)
+return;
+  }
   mainloop_event_activate(postloop_cleanup_ev);
 }
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [doctor/master] Use new methods to reference diretories

2018-05-10 Thread atagar
commit 49cce6ce032d36c35f65a43ad17efe01a5d403a1
Author: Damian Johnson 
Date:   Thu May 10 12:51:21 2018 -0700

Use new methods to reference diretories

Using stem's new stem.directory module rather than the deprecated aliases.
---
 consensus_health_checker.py | 3 ++-
 descriptor_checker.py   | 3 ++-
 fallback_directories.py | 7 ---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index 9710b5e..993ef73 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -16,6 +16,7 @@ import util
 
 import stem.descriptor
 import stem.descriptor.remote
+import stem.directory
 import stem.util.conf
 import stem.util.enum
 
@@ -24,7 +25,7 @@ from stem.util.lru_cache import lru_cache
 
 Runlevel = stem.util.enum.UppercaseEnum('NOTICE', 'WARNING', 'ERROR')
 
-DIRECTORY_AUTHORITIES = stem.descriptor.remote.get_authorities()
+DIRECTORY_AUTHORITIES = stem.directory.Authority.from_cache()
 del DIRECTORY_AUTHORITIES['tor26']  # DirPort does not service requests 
without a '.z' suffix
 
 EMAIL_SUBJECT = 'Consensus issues'
diff --git a/descriptor_checker.py b/descriptor_checker.py
index fd7c91d..9764f87 100755
--- a/descriptor_checker.py
+++ b/descriptor_checker.py
@@ -17,6 +17,7 @@ import util
 
 import stem.descriptor
 import stem.descriptor.remote
+import stem.directory
 
 EMAIL_SUBJECT = 'Unable to retrieve tor descriptors'
 
@@ -61,7 +62,7 @@ def main():
 
   # download the consensus from each authority
 
-  for authority in stem.descriptor.remote.get_authorities().values():
+  for authority in stem.directory.Authority.from_cache().values():
 if authority.v3ident is None:
   continue  # authority doesn't vote in the consensus
 elif authority.nickname == 'tor26':
diff --git a/fallback_directories.py b/fallback_directories.py
index 8ede789..3e4ce06 100755
--- a/fallback_directories.py
+++ b/fallback_directories.py
@@ -9,7 +9,8 @@ Report for how many of our fallback directories are unreachable.
 import time
 import traceback
 
-from stem.descriptor.remote import DescriptorDownloader, FallbackDirectory
+import stem.descriptor.remote
+import stem.directory
 
 import util
 
@@ -24,12 +25,12 @@ EMAIL_BODY = """\
 
 """
 
-downloader = DescriptorDownloader(timeout = 30)
+downloader = stem.descriptor.remote.DescriptorDownloader(timeout = 30)
 
 
 def main():
   try:
-fallback_directories = FallbackDirectory.from_remote().values()
+fallback_directories = stem.directory.Fallback.from_remote().values()
 log.info('Retrieved %i fallback directories' % len(fallback_directories))
   except IOError as exc:
 raise IOError("Unable to determine tor's fallback directories: %s" % exc)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [doctor/master] Track expiring approved-routers.conf entries from 2016-01 to 2018-01

2018-05-10 Thread atagar
commit 7ffb7869438babe6fc2aa8b8b3e0f6cfc10b7f5a
Author: David Goulet 
Date:   Tue May 8 16:18:46 2018 -0400

Track expiring approved-routers.conf entries from 2016-01 to 2018-01

This adds the fingerprint entries from approved-routers.conf. 3 months
expiry date has been set for those.

Closes #26055

Signed-off-by: David Goulet 
---
 data/tracked_relays.cfg | 794 
 1 file changed, 794 insertions(+)

diff --git a/data/tracked_relays.cfg b/data/tracked_relays.cfg
index 5749d08..9322fc7 100644
--- a/data/tracked_relays.cfg
+++ b/data/tracked_relays.cfg
@@ -1317,3 +1317,797 @@ Expiring-old-address.address 96.43.142.28
 Expiring-old-address.address 97.107.132.20
 Expiring-old-address.address 97.107.139.42
 Expiring-old-address.address 97.107.140.77
+
+Expiring-old-approved-routers.description Entries from 2016-01 to 2018-01 from 
approved-routers.conf
+Expiring-old-approved-routers.expires 2018-08-01
+Expiring-old-approved-routers.fingerprint 
00161E152FCF43380176F13B964656BD243D6F33
+Expiring-old-approved-routers.fingerprint 
0024D445B3D1E1BE436C9A8F6082E8B7DFA4AEB2
+Expiring-old-approved-routers.fingerprint 
006D1F9E6D74D3E195C9054C2818CF6E9C8CB438
+Expiring-old-approved-routers.fingerprint 
00DC6C4FA49A65BD1472993CF6730D54F11E0DBB
+Expiring-old-approved-routers.fingerprint 
00F6F9956A6747691E942415BCF5D8EE806B9E49
+Expiring-old-approved-routers.fingerprint 
0100F6C13609EE307687FA56CDA24CE2BFE9C612
+Expiring-old-approved-routers.fingerprint 
011F2599C0E9B27EE74B353155E244813763C3E5
+Expiring-old-approved-routers.fingerprint 
01370A8E1F908B63121B5A098A26DE79078D8205
+Expiring-old-approved-routers.fingerprint 
015CD3F2D07C4B66419858A1912B9F1C82EEB1BF
+Expiring-old-approved-routers.fingerprint 
01E3B3E14F80B2BE2351A892FBD894DAC35EF26B
+Expiring-old-approved-routers.fingerprint 
01F00C6FDB87B5CE6FF25133825FD0A43A960633
+Expiring-old-approved-routers.fingerprint 
021705C9254015B3EC3925F251E7ED9662AA2FBB
+Expiring-old-approved-routers.fingerprint 
0242F3CB4D400C1FF59F827531D35C549CEC461C
+Expiring-old-approved-routers.fingerprint 
0319F7F4ADCDDB065BCBB9119F066D760142DC20
+Expiring-old-approved-routers.fingerprint 
03807F964EFAB4E7DB431FA67CBF896347FEBDAD
+Expiring-old-approved-routers.fingerprint 
03DD8611155A2A2399FC6C272863B7C15B65FDED
+Expiring-old-approved-routers.fingerprint 
03E34DA96F4D4D1134D1B529C726B2162F7FE98F
+Expiring-old-approved-routers.fingerprint 
04949C507F99D25D10CEC086B530169B28E25CAC
+Expiring-old-approved-routers.fingerprint 
049C2481B42FE77FE2747B020874028590A57BE6
+Expiring-old-approved-routers.fingerprint 
04D2D11BBD2A2DCD78CA102EBB9337BDFD1B760E
+Expiring-old-approved-routers.fingerprint 
04F0C6F4D5731A6D6D08C104D894C78C6692AC7C
+Expiring-old-approved-routers.fingerprint 
0530FE7CB9065B9ECA9099FB180B8EA2B2EFF4FD
+Expiring-old-approved-routers.fingerprint 
0639612FF149AA19DF3BCEA147E5B8FED6F3C87C
+Expiring-old-approved-routers.fingerprint 
066FBB2661004A85E86DC9992CE31E8F41DF3DF2
+Expiring-old-approved-routers.fingerprint 
070EF06A4CDFB1FCFB0C3085AA5C03D2802BCE7E
+Expiring-old-approved-routers.fingerprint 
079B235C5D4FCE3C7701285EB9B5535062BA9971
+Expiring-old-approved-routers.fingerprint 
079B6B385F1F13AF7AB93EEC671A24AB8427C92F
+Expiring-old-approved-routers.fingerprint 
07A7B5E0AD461F7EF1C2589CCF051E97F5FCA8D9
+Expiring-old-approved-routers.fingerprint 
07BB9A66154A2B481C5006DC973EA3D38D8940F3
+Expiring-old-approved-routers.fingerprint 
07CB43980A7C2135F042F569EB08BBCA55EB3A27
+Expiring-old-approved-routers.fingerprint 
07CDF1522213F3CA1B8D0149A4E011630375A4DB
+Expiring-old-approved-routers.fingerprint 
084B5AA77FDE374A50AD3B50A49FF85A22F5B389
+Expiring-old-approved-routers.fingerprint 
088811C45F5AC62FBE4D09357FA59613707E291F
+Expiring-old-approved-routers.fingerprint 
08B7BC7EC69038DC46A90C429A68FFF3675F2652
+Expiring-old-approved-routers.fingerprint 
090278625E7D3C64E959D285D26837E28EE89956
+Expiring-old-approved-routers.fingerprint 
094E85E17C727628839CC3CCF2EC769DD072FD0A
+Expiring-old-approved-routers.fingerprint 
094F055B608C4FEC4A3E25795C76DBBCCC856934
+Expiring-old-approved-routers.fingerprint 
09826F21BC9CF2B0B69A0550141E7EC155630EBA
+Expiring-old-approved-routers.fingerprint 
098D9352D8BC7C13367D1CE44A625F29F8ABA8AE
+Expiring-old-approved-routers.fingerprint 
09B73F27632534F0B418D661B0EF2CE1E952CF16
+Expiring-old-approved-routers.fingerprint 
09E1A324B6238DE26E26703D452F1218A64A9A22
+Expiring-old-approved-routers.fingerprint 
0A619576783E0F92BE64FCE3D4D295DBEFAF27F0
+Expiring-old-approved-routers.fingerprint 
0A6E6903E2969ED18634FA8BDC86B72B50511214
+Expiring-old-approved-routers.fingerprint 
0ABE4B6AA76AF8F7E90980887BDBFE3BE81D7616
+Expiring-old-approved-routers.fingerprint 
0B5696B2AA395F76D3E56730240A56905275ED74
+Expiring-old-approved-routers.fingerprint 
0BAC39417268B96B9F514E7F63FA6FBA1A788955
+Expiring-old-approved-routers.fingerprint 

[tor-commits] [doctor/master] Track expiring bad.conf entries from 2016-01 to 2018-01

2018-05-10 Thread atagar
commit c29bba1efb92927b975cd863bb4f437792947a67
Author: David Goulet 
Date:   Tue May 8 16:15:56 2018 -0400

Track expiring bad.conf entries from 2016-01 to 2018-01

This only adds the IP address from bad.conf. 3 months expiry date has
been set for those.

The fingerprints from approved-routers.conf are coming in a second
following commit.

Part of #26055

Signed-off-by: David Goulet 
---
 data/tracked_relays.cfg | 1299 ++-
 1 file changed, 1298 insertions(+), 1 deletion(-)

diff --git a/data/tracked_relays.cfg b/data/tracked_relays.cfg
index e25959e..5749d08 100644
--- a/data/tracked_relays.cfg
+++ b/data/tracked_relays.cfg
@@ -19,4 +19,1301 @@
 #   Unnamed001.description harvesting hidden services on 2012-08-12
 #   Unnamed001.expires 2016-03-01
 #   Unnamed001.fingerprint 05AF83344B3787D0DCCD47DC4A6A4668142A5F8C
-
+Expiring-old-address.description Entries from 2016-01-01 to 2018-01-01
+Expiring-old-address.expires 2018-08-01
+Expiring-old-address.address 100.15.101.233
+Expiring-old-address.address 101.55.74.23
+Expiring-old-address.address 103.16.27.75
+Expiring-old-address.address 103.16.27.81
+Expiring-old-address.address 103.199.16.58
+Expiring-old-address.address 103.27.126.27
+Expiring-old-address.address 103.27.126.28
+Expiring-old-address.address 103.29.68.200
+Expiring-old-address.address 103.3.61.219
+Expiring-old-address.address 103.3.62.84
+Expiring-old-address.address 103.3.63.75
+Expiring-old-address.address 103.44.66.2
+Expiring-old-address.address 103.44.66.4
+Expiring-old-address.address 103.44.66.5
+Expiring-old-address.address 103.6.87.106
+Expiring-old-address.address 104.129.41.28
+Expiring-old-address.address 104.131.132.110
+Expiring-old-address.address 104.131.138.76
+Expiring-old-address.address 104.131.140.142
+Expiring-old-address.address 104.131.141.157
+Expiring-old-address.address 104.148.13.21
+Expiring-old-address.address 104.148.13.23
+Expiring-old-address.address 104.148.13.25
+Expiring-old-address.address 104.148.13.28
+Expiring-old-address.address 104.155.225.109
+Expiring-old-address.address 104.156.233.70
+Expiring-old-address.address 104.156.233.70
+Expiring-old-address.address 104.177.150.66
+Expiring-old-address.address 104.196.119.128
+Expiring-old-address.address 104.197.108.159
+Expiring-old-address.address 104.197.63.94
+Expiring-old-address.address 104.198.204.8
+Expiring-old-address.address 104.207.133.1
+Expiring-old-address.address 104.207.134.169
+Expiring-old-address.address 104.207.142.152
+Expiring-old-address.address 104.207.147.108
+Expiring-old-address.address 104.223.137.19
+Expiring-old-address.address 104.223.137.26
+Expiring-old-address.address 104.223.137.30
+Expiring-old-address.address 104.223.139.19
+Expiring-old-address.address 104.223.139.21
+Expiring-old-address.address 104.223.139.23
+Expiring-old-address.address 104.223.139.25
+Expiring-old-address.address 104.223.141.15
+Expiring-old-address.address 104.223.141.15
+Expiring-old-address.address 104.223.141.24
+Expiring-old-address.address 104.223.141.25
+Expiring-old-address.address 104.223.141.30
+Expiring-old-address.address 104.223.144.13
+Expiring-old-address.address 104.223.144.15
+Expiring-old-address.address 104.223.144.18
+Expiring-old-address.address 104.223.144.23
+Expiring-old-address.address 104.223.144.23
+Expiring-old-address.address 104.223.144.29
+Expiring-old-address.address 104.223.144.29
+Expiring-old-address.address 104.223.144.3
+Expiring-old-address.address 104.223.144.6
+Expiring-old-address.address 104.223.146.25
+Expiring-old-address.address 104.223.146.28
+Expiring-old-address.address 104.223.146.7
+Expiring-old-address.address 104.223.147.11
+Expiring-old-address.address 104.223.147.12
+Expiring-old-address.address 104.223.147.14
+Expiring-old-address.address 104.223.147.16
+Expiring-old-address.address 104.223.147.22
+Expiring-old-address.address 104.223.147.29
+Expiring-old-address.address 104.223.147.4
+Expiring-old-address.address 104.223.147.6
+Expiring-old-address.address 104.224.143.177
+Expiring-old-address.address 104.224.143.177
+Expiring-old-address.address 104.224.144.236
+Expiring-old-address.address 104.224.144.236
+Expiring-old-address.address 104.224.150.29
+Expiring-old-address.address 104.224.150.29
+Expiring-old-address.address 104.224.165.201
+Expiring-old-address.address 104.224.165.201
+Expiring-old-address.address 104.236.12.51
+Expiring-old-address.address 104.236.13.251
+Expiring-old-address.address 104.236.132.64
+Expiring-old-address.address 104.236.141.96
+Expiring-old-address.address 104.236.158.82
+Expiring-old-address.address 104.236.182.90
+Expiring-old-address.address 104.236.187.58
+Expiring-old-address.address 104.236.231.245
+Expiring-old-address.address 104.238.138.240
+Expiring-old-address.address 104.238.138.62
+Expiring-old-address.address 104.238.145.220
+Expiring-old-address.address 

[tor-commits] [stem/master] Timeout support in controller methods that await something

2018-05-10 Thread atagar
commit 8a065f42952c9dc9762eaebe4d3fa48210783998
Author: Damian Johnson 
Date:   Thu May 10 12:39:29 2018 -0700

Timeout support in controller methods that await something

Adding a timeout argument to all controller methods with an 'await' option.

  https://trac.torproject.org/projects/tor/ticket/26056
---
 docs/change_log.rst |  1 +
 stem/__init__.py| 26 +++--
 stem/control.py | 65 +
 test/unit/control/controller.py | 13 +
 4 files changed, 90 insertions(+), 15 deletions(-)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 3836b8ad..720c636d 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -48,6 +48,7 @@ The following are only available within Stem's `git repository
 
   * Documented v3 hidden service support (:trac:`25124`, :spec:`6bd0a69`)
   * Added support for limiting the maximum number of streams to 
:func:`~stem.control.Controller.create_ephemeral_hidden_service` 
(:spec:`2fcb1c2`)
+  * Added a timeout argument to :class:`~stem.control.Controller` methods that 
could await a response (:trac:`26056`)
   * Stacktrace if :func:`stem.connection.connect` had a string port argument
   * More reliable ExitPolicy resolution (:trac:`25739`)
   * Replaced socket's :func:`~stem.socket.ControlPort.get_address`, 
:func:`~stem.socket.ControlPort.get_port`, and 
:func:`~stem.socket.ControlSocketFile.get_socket_path` with attributes
diff --git a/stem/__init__.py b/stem/__init__.py
index 0104d3b2..e9ad8430 100644
--- a/stem/__init__.py
+++ b/stem/__init__.py
@@ -10,12 +10,17 @@ Library for working with the tor process.
 
   ControllerError - Base exception raised when using the controller.
 |- ProtocolError - Malformed socket data.
+|
 |- OperationFailed - Tor was unable to successfully complete the operation.
 |  |- UnsatisfiableRequest - Tor was unable to satisfy a valid request.
-|  |  +- CircuitExtensionFailed - Attempt to make or extend a circuit 
failed.
-|  |- DescriptorUnavailable - The given relay descriptor is unavailable.
+|  |  |- CircuitExtensionFailed - Attempt to make or extend a circuit 
failed.
+|  |  |- DescriptorUnavailable - The given relay descriptor is unavailable.
+|  |  +- Timeout - Caller requested timeout was reached.
+|  |
+|  |
 |  +- InvalidRequest - Invalid request.
 | +- InvalidArguments - Invalid request parameters.
+|
 +- SocketError - Communication with the socket failed.
+- SocketClosed - Socket has been shut down.
 
@@ -504,6 +509,7 @@ __all__ = [
   'UnsatisfiableRequest',
   'CircuitExtensionFailed',
   'DescriptorUnavailable',
+  'Timeout',
   'InvalidRequest',
   'InvalidArguments',
   'SocketError',
@@ -582,15 +588,29 @@ class CircuitExtensionFailed(UnsatisfiableRequest):
 self.circ = circ
 
 
-class DescriptorUnavailable(OperationFailed):
+class DescriptorUnavailable(UnsatisfiableRequest):
   """
   Tor was unable to provide a descriptor for the given relay.
+
+  .. versionchanged:: 1.7.0
+ Subclassed under UnsatisfiableRequest rather than OperationFailed.
   """
 
   def __init__(self, message):
 super(DescriptorUnavailable, self).__init__(message = message)
 
 
+class Timeout(UnsatisfiableRequest):
+  """
+  Timeout requested by the caller was reached.
+
+  .. versionadded:: 1.7.0
+  """
+
+  def __init__(self, message):
+super(Timeout, self).__init__(message = message)
+
+
 class InvalidRequest(OperationFailed):
   """
   Exception raised when the request was invalid or malformed.
diff --git a/stem/control.py b/stem/control.py
index fd9aa8dc..244aed0b 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1992,7 +1992,7 @@ class Controller(BaseController):
   yield desc
 
   @with_default()
-  def get_hidden_service_descriptor(self, address, default = UNDEFINED, 
servers = None, await_result = True):
+  def get_hidden_service_descriptor(self, address, default = UNDEFINED, 
servers = None, await_result = True, timeout = None):
 """
 get_hidden_service_descriptor(address, default = UNDEFINED, servers = 
None, await_result = True)
 
@@ -2007,9 +2007,13 @@ class Controller(BaseController):
 
 .. versionadded:: 1.4.0
 
+.. versionchanged:: 1.7.0
+   Added the timeout argument.
+
 :param str address: address of the hidden service descriptor, the '.onion' 
suffix is optional
 :param object default: response if the query fails
 :param list servers: requrest the descriptor from these specific servers
+:param float timeout: seconds to wait when **await_result** is **True**
 
 :returns: 
:class:`~stem.descriptor.hidden_service_descriptor.HiddenServiceDescriptor`
   for the given service if **await_result** is **True**, or **None** 
otherwise
@@ -2017,6 +2021,7 @@ class Controller(BaseController):
 :raises:
   * :class:`stem.DescriptorUnavailable` if **await_result** is 

[tor-commits] [translation/support-connecting] Update translations for support-connecting

2018-05-10 Thread translation
commit d0a2630acaeec1d4efafe0dcd083e44fac4d25f2
Author: Translation commit bot 
Date:   Thu May 10 14:19:06 2018 +

Update translations for support-connecting
---
 pt_BR.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pt_BR.json b/pt_BR.json
index b9cc3f9b8..222d00ffd 100644
--- a/pt_BR.json
+++ b/pt_BR.json
@@ -2,7 +2,7 @@
 "connecting-1": {
"id": "#conectando-1",
"control": "conectando-1",
-   "title": "O Tor Browser não está funcionando, mas não parece ser 
algo relacionado à censura.",
+   "title": "O Tor Browser não está funcionando, mas não parece ser 
algo relacionado a censura.",
"description": "Um dos problemas mais comuns que 
causa erros de conexão no Navegador Tor é um relógio do sistema incorreto. 
Por favor, certifique-se de que o relógio do sistema e o fuso horário estejam 
definidos com precisão. Se isso não resolver o problema, consulte a página 
Solução de Problemas no manual do Navegador Tor."
 },
 "connecting-2": {

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [translation/tor-browser-manual] Update translations for tor-browser-manual

2018-05-10 Thread translation
commit 55efc3b70ea7ea86f5d1964845e0bfeb1f45a477
Author: Translation commit bot 
Date:   Thu May 10 14:18:46 2018 +

Update translations for tor-browser-manual
---
 pt_BR/pt_BR.po | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pt_BR/pt_BR.po b/pt_BR/pt_BR.po
index 2c19a341c..1028b5b39 100644
--- a/pt_BR/pt_BR.po
+++ b/pt_BR/pt_BR.po
@@ -1083,7 +1083,7 @@ msgid ""
 "connecting to http://3g2upl4pq6kufc4m.onion/\;>DuckDuckGo's "
 "Onion Service"
 msgstr ""
-"Você pode garantir o seu acesso a outros serviços onion conectando-se ao "
+"Para garantir seu acesso a outros serviços onion, você pode se conectar aos 
"
 "http://3g2upl4pq6kufc4m.onion/\;>Serviços Onion do "
 "DuckDuckGo"
 

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [translation/tor-browser-manual_completed] Update translations for tor-browser-manual_completed

2018-05-10 Thread translation
commit dc7f76909ed0979680de3b63b62d451f16dff2b5
Author: Translation commit bot 
Date:   Thu May 10 14:18:54 2018 +

Update translations for tor-browser-manual_completed
---
 pt_BR/pt_BR.po | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pt_BR/pt_BR.po b/pt_BR/pt_BR.po
index 2c19a341c..1028b5b39 100644
--- a/pt_BR/pt_BR.po
+++ b/pt_BR/pt_BR.po
@@ -1083,7 +1083,7 @@ msgid ""
 "connecting to http://3g2upl4pq6kufc4m.onion/\;>DuckDuckGo's "
 "Onion Service"
 msgstr ""
-"Você pode garantir o seu acesso a outros serviços onion conectando-se ao "
+"Para garantir seu acesso a outros serviços onion, você pode se conectar aos 
"
 "http://3g2upl4pq6kufc4m.onion/\;>Serviços Onion do "
 "DuckDuckGo"
 

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [translation/support-tbb] Update translations for support-tbb

2018-05-10 Thread translation
commit e16d064e010e398cd66e039fa170556e27dd2fe7
Author: Translation commit bot 
Date:   Thu May 10 13:49:44 2018 +

Update translations for support-tbb
---
 id.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/id.json b/id.json
index d9ed56dfc..02e0cce73 100644
--- a/id.json
+++ b/id.json
@@ -249,7 +249,7 @@
"id": "#tbb-41",
"control": "tbb-41",
"title": "Kenapa mesin pencari Saya berubah menjadi DuckDuckGo?",
-   "description": "With the release of Tor Browser 
6.0.6, we switched to DuckDuckGo as the primary search engine. For a while now, 
Disconnect has had no access to Google search results which we used in Tor 
Browser. Disconnect being more of a meta search engine which allows users to 
choose between different search providers fell back to delivering Bing search 
results which were basically unacceptable quality-wise."
+   "description": "Pada rilis Tor Browser 6.0.6, kami 
pindah ke DuckDuckGo sebagai mesin pencari utama. Sudah beberapa lama ini, 
Disconnect tidak dapat mengakses hasil pencarian Google yang kami gunakan di 
Tor Browser. Disconnect adalah mesin pencari meta yang membuat pengguna memilih 
mesin pencari yang berbeda, yang seringnya mengambil hasil cari dari Bing, yang 
kualitasnya diragukan."
 },
  "tbb-42": {
"id": "#tbb-42",

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit b343ba90604de524b5fa7d87a6daf76fcc118adb
Merge: f64fa6b19 7ee67c47f
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Merge branch 'maint-0.3.1' into release-0.3.1

2018-05-10 Thread nickm
commit d47da400584900193d61d8feaf874a0ff2abec13
Merge: 5fd8f3b71 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into release-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 7ee67c47fae2263e8c4f5599e0fbba6531738120
Merge: 15b8c860d 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 7ee67c47fae2263e8c4f5599e0fbba6531738120
Merge: 15b8c860d 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.3' into release-0.3.3

2018-05-10 Thread nickm
commit 1118536142d03ab3e3958788c9bedd354b9fc8fa
Merge: f36fea697 b343ba906
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.3' into release-0.3.3

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.3'

2018-05-10 Thread nickm
commit 382beb93cb4110b2bcc82ab69c8e72c274a51ca2
Merge: 2eff709ed b343ba906
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.3'

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge branch 'maint-0.3.2' into release-0.3.2

2018-05-10 Thread nickm
commit e935e2767676d86d9b36b6aafb439075a71feab0
Merge: 34d418009 7ee67c47f
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.2' into release-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit b343ba90604de524b5fa7d87a6daf76fcc118adb
Merge: f64fa6b19 7ee67c47f
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 7ee67c47fae2263e8c4f5599e0fbba6531738120
Merge: 15b8c860d 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 7ee67c47fae2263e8c4f5599e0fbba6531738120
Merge: 15b8c860d 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit b343ba90604de524b5fa7d87a6daf76fcc118adb
Merge: f64fa6b19 7ee67c47f
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

2018-05-10 Thread nickm
commit 2d61a83513d4537735843f50c1766c224dd86183
Merge: ba7043921 6e99286d4
Author: Nick Mathewson 
Date:   Thu May 10 09:22:14 2018 -0400

Merge remote-tracking branch 'dgoulet/bug26069_031_01' into maint-0.3.1

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] hs-v3: Add an extra white-space when parsing descriptor

2018-05-10 Thread nickm
commit 6e99286d45be482effe47feb057948b98495a49f
Author: David Goulet 
Date:   Thu May 10 09:16:50 2018 -0400

hs-v3: Add an extra white-space when parsing descriptor

The specification describes the signature token to be right after a newline
(\n) then the token "signature" and then a white-space followed by the 
encoded
signature.

This commit makes sure that when we parse the signature from the descriptor,
we are always looking for that extra white-space at the end of the token.

It will allow us also to support future fields that might start with
"signature".

Fixes #26069

Signed-off-by: David Goulet 
---
 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug26069 b/changes/bug26069
new file mode 100644
index 0..192e97d78
--- /dev/null
+++ b/changes/bug26069
@@ -0,0 +1,5 @@
+  o Minor bugfixes (hidden service v3):
+- When parsing the descriptor signature, look for the token plus an extra
+  white-space at the end. This is more correct but also will allow us to
+  support new fields that might start with "signature". Fixes bug 26069;
+  bugfix on 0.3.0.1-alpha.
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index fae527b2d..3ec02618b 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -1849,7 +1849,7 @@ desc_sig_is_valid(const char *b64_sig,
   }
 
   /* Find the start of signature. */
-  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature);
+  sig_start = tor_memstr(encoded_desc, encoded_len, "\n" str_signature " ");
   /* Getting here means the token parsing worked for the signature so if we
* can't find the start of the signature, we have a code flow issue. */
   if (!sig_start) {



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge branch 'maint-0.3.2' into release-0.3.2

2018-05-10 Thread nickm
commit 34d418009d99931000870b535222e901ace52c1f
Merge: a15009bd3 15b8c860d
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.2' into release-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 7ee67c47fae2263e8c4f5599e0fbba6531738120
Merge: 15b8c860d 2d61a8351
Author: Nick Mathewson 
Date:   Thu May 10 09:22:32 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 changes/bug26069   | 5 +
 src/or/hs_descriptor.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Merge branch 'maint-0.3.1' into release-0.3.1

2018-05-10 Thread nickm
commit 5fd8f3b71d5c0d8dc9827d107215af91ecae4d78
Merge: 9ca9e6a1f ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into release-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 15b8c860d3c8eac8f560569a90e90ba517e1c6ae
Merge: e5acbbd16 ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit f64fa6b19ec7663f47e600599761fadbde4135e9
Merge: 59812789f 15b8c860d
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit f64fa6b19ec7663f47e600599761fadbde4135e9
Merge: 59812789f 15b8c860d
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.2.9] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.2.9] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.3] Merge branch 'maint-0.3.3' into release-0.3.3

2018-05-10 Thread nickm
commit f36fea697eb480d9e67cfbd69b122427802fea85
Merge: 62b224f72 f64fa6b19
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.3' into release-0.3.3

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.1] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.3.2] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 15b8c860d3c8eac8f560569a90e90ba517e1c6ae
Merge: e5acbbd16 ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 15b8c860d3c8eac8f560569a90e90ba517e1c6ae
Merge: e5acbbd16 ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 15b8c860d3c8eac8f560569a90e90ba517e1c6ae
Merge: e5acbbd16 ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.2.9] Merge branch 'maint-0.2.9' into release-0.2.9

2018-05-10 Thread nickm
commit a1c06b84b31cbc1c7e0f57928de66d9d1159ce4a
Merge: 52bb38868 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into release-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/release-0.2.9] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge branch 'maint-0.3.1' into maint-0.3.2

2018-05-10 Thread nickm
commit 15b8c860d3c8eac8f560569a90e90ba517e1c6ae
Merge: e5acbbd16 ba7043921
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.1' into maint-0.3.2

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.3] Merge branch 'maint-0.3.2' into maint-0.3.3

2018-05-10 Thread nickm
commit f64fa6b19ec7663f47e600599761fadbde4135e9
Merge: 59812789f 15b8c860d
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.2' into maint-0.3.3

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'maint-0.3.3'

2018-05-10 Thread nickm
commit 2eff709edb52e2bf6565dd8d00d7f2b79a05e60c
Merge: 1eede00a4 f64fa6b19
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.3.3'

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] Merge branch 'maint-0.2.9' into maint-0.3.1

2018-05-10 Thread nickm
commit ba70439210c57b0e0e60b07f116f101725085d85
Merge: aa08c1970 edb6acf9c
Author: Nick Mathewson 
Date:   Thu May 10 09:19:28 2018 -0400

Merge branch 'maint-0.2.9' into maint-0.3.1

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.2] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.2.9] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.2.9] Stop logging stack contents when reading a zero-length bandwidth file

2018-05-10 Thread nickm
commit 867fe40f91b849393b56109586d85e499a53a142
Author: teor 
Date:   Wed May 2 22:33:21 2018 +1000

Stop logging stack contents when reading a zero-length bandwidth file

When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.

Fixes bug 26007; bugfix on 0.2.2.1-alpha.
---
 changes/bug26007 |  5 +
 src/or/dirserv.c | 13 +++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/changes/bug26007 b/changes/bug26007
new file mode 100644
index 0..efcd15084
--- /dev/null
+++ b/changes/bug26007
@@ -0,0 +1,5 @@
+  o Major bugfixes (directory authorities, security):
+- When directory authorities read a zero-byte bandwidth file, they log
+  a warning with the contents of an uninitialised buffer. Log a warning
+  about the empty file instead.
+  Fixes bug 26007; bugfix on 0.2.2.1-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 41c6bf3dc..94290d5dd 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2750,14 +2750,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
   time_t file_time, now;
   int ok;
 
+  /* Initialise line, so that we can't possibly run off the end. */
+  memset(line, 0, sizeof(line));
+
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
 return -1;
   }
 
-  if (!fgets(line, sizeof(line), fp)
-  || !strlen(line) || line[strlen(line)-1] != '\n') {
+  /* If fgets fails, line is either unmodified, or indeterminate. */
+  if (!fgets(line, sizeof(line), fp)) {
+log_warn(LD_DIRSERV, "Empty bandwidth file");
+fclose(fp);
+return -1;
+  }
+
+  if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
 fclose(fp);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.3.1] Test read bandwidth measurements with empty file

2018-05-10 Thread nickm
commit dbdde76f56d0ecb2ef03ac6ec231151016ffbd88
Author: juga0 
Date:   Tue May 8 16:23:37 2018 +

Test read bandwidth measurements with empty file
---
 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index cdc56acb8..ad5f08643 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1368,6 +1368,25 @@ test_dir_measured_bw_kb(void *arg)
   return;
 }
 
+/* Test dirserv_read_measured_bandwidths */
+static void
+test_dir_dirserv_read_measured_bandwidths(void *arg)
+{
+  char *fname=NULL;
+  (void)arg;
+
+  fname = tor_strdup(get_fname("V3BandwidthsFile"));
+  /* Test an empty file */
+  write_str_to_file(fname, "", 0);
+  setup_capture_of_logs(LOG_WARN);
+  tt_int_op(-1, OP_EQ, dirserv_read_measured_bandwidths(fname, NULL));
+  expect_log_msg("Empty bandwidth file\n");
+
+ done:
+  tor_free(fname);
+  teardown_capture_of_logs();
+}
+
 #define MBWC_INIT_TIME 1000
 
 /** Do the measured bandwidth cache unit test */
@@ -5458,6 +5477,7 @@ struct testcase_t dir_tests[] = {
   DIR_LEGACY(versions),
   DIR_LEGACY(fp_pairs),
   DIR(split_fps, 0),
+  DIR_LEGACY(dirserv_read_measured_bandwidths),
   DIR_LEGACY(measured_bw_kb),
   DIR_LEGACY(measured_bw_kb_cache),
   DIR_LEGACY(param_voting),



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.2.9] Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

2018-05-10 Thread nickm
commit edb6acf9cee42406cfa8380c898b7b664f699b8d
Merge: bca8a104b dbdde76f5
Author: Nick Mathewson 
Date:   Thu May 10 09:19:09 2018 -0400

Merge remote-tracking branch 'juga/ticket26007_029_02' into maint-0.2.9

 src/test/test_dir.c | 20 
 1 file changed, 20 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [translation/support-tbb] Update translations for support-tbb

2018-05-10 Thread translation
commit f13706138b2571980683b8009e10cbbae8dcb2c4
Author: Translation commit bot 
Date:   Thu May 10 13:19:28 2018 +

Update translations for support-tbb
---
 id.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/id.json b/id.json
index 600ae0101..d9ed56dfc 100644
--- a/id.json
+++ b/id.json
@@ -195,7 +195,7 @@
"id": "#tbb-32",
"control": "tbb-32",
"title": "Apakah saya dapat membuat Tor Browser menjadi peramban 
standar saya?",
-   "description": "There is currently no supported 
method for setting Tor Browser as your default browser. The Tor Browser works 
hard to isolate itself from the rest of your system, and the steps for making 
it the default browser are unreliable. This means sometimes a website would 
load in the Tor Browser, and sometimes it would load in another browser, this 
type of behavior can be dangerous and anonymity-breaking."
+   "description": "Saat ini tidak ada metode yang 
didukung untuk membuat Tor Browser sebagai peramban standar. Tor Browser 
bekerja keras untuk mengisolasi dirinya dari sistem operasi yang Anda gunakan, 
dan membuatnya sebagai peramban standar adalah cara yang sangat tidak handal. 
Ini artinya kadang sebuah situs web akan terbuka di Tor Browser, dan kadang 
terbuka di peramban lain. Perilaku seperti ini akan berbahaya dan akan 
menghancurkan anonimitas."
 },
 "tbb-33": {
"id": "#tbb-33",
@@ -213,7 +213,7 @@
"id": "#tbb-35",
"control": "tbb-35",
"title": "Bagaimana cara menghilangkan semua captchas?",
-   "description": "Unfortunately, some websites deliver 
CAPTCHAS to Tor users, and we are not able to remove CAPTCHAs from websites. 
The best thing to do in these cases is to contact the website owners, and 
inform them that their CAPTCHAs are preventing users such as yourself from 
using their services."
+   "description": "Sayangnya, beberapa situs web 
menampilkan CAPTCHAS ke pengguna Tor, dan kami tidak dapat memblokir CAPTCHAs 
dari situs web. Hal terbaik yang dapat dilakukan adalah menghubungi pemilik 
situs web yang bersangkutan dan memberitahukan bahwa  CAPTCHA yang digunakan di 
situs web mereka menghalangi pengguna seperti Anda dari menggunakan servis 
mereka."
 },
 "tbb-36": {
"id": "#tbb-36",

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Add a new function to enable/disable the per-second timer as needed

2018-05-10 Thread nickm
commit e722bba263e6c4648fff4259a14677993697337c
Author: Nick Mathewson 
Date:   Wed May 9 12:40:45 2018 -0400

Add a new function to enable/disable the per-second timer as needed

We're about to use this to turn off the per-second timer when the
network is disabled and there aren't any per-second controller
events enabled.
---
 src/or/main.c | 42 +++---
 src/or/main.h |  1 +
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/or/main.c b/src/or/main.c
index 682ec29ab..0493596aa 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2491,6 +2491,36 @@ hs_service_callback(time_t now, const or_options_t 
*options)
 
 /** Timer: used to invoke second_elapsed_callback() once per second. */
 static periodic_timer_t *second_timer = NULL;
+
+/**
+ * Enable or disable the per-second timer as appropriate, creating it if
+ * necessary.
+ */
+void
+reschedule_per_second_timer(void)
+{
+  struct timeval one_second;
+  one_second.tv_sec = 1;
+  one_second.tv_usec = 0;
+
+  if (! second_timer) {
+second_timer = periodic_timer_new(tor_libevent_get_base(),
+  _second,
+  second_elapsed_callback,
+  NULL);
+tor_assert(second_timer);
+  }
+
+  const bool run_per_second_events =
+control_any_per_second_event_enabled() || ! net_is_completely_disabled();
+
+  if (run_per_second_events) {
+periodic_timer_launch(second_timer, _second);
+  } else {
+periodic_timer_disable(second_timer);
+  }
+}
+
 /** Number of libevent errors in the last second: we die if we get too many. */
 static int n_libevent_errors = 0;
 /** Last time that second_elapsed_callback was called. */
@@ -2824,17 +2854,7 @@ do_main_loop(void)
   }
 
   /* set up once-a-second callback. */
-  if (! second_timer) {
-struct timeval one_second;
-one_second.tv_sec = 1;
-one_second.tv_usec = 0;
-
-second_timer = periodic_timer_new(tor_libevent_get_base(),
-  _second,
-  second_elapsed_callback,
-  NULL);
-tor_assert(second_timer);
-  }
+  reschedule_per_second_timer();
 
 #ifdef HAVE_SYSTEMD_209
   uint64_t watchdog_delay;
diff --git a/src/or/main.h b/src/or/main.h
index a312b51e0..3cfa9c82b 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -92,6 +92,7 @@ uint64_t get_main_loop_error_count(void);
 uint64_t get_main_loop_idle_count(void);
 
 void periodic_events_on_new_options(const or_options_t *options);
+void reschedule_per_second_timer(void);
 
 extern time_t time_of_process_start;
 extern int quiet_level;



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Remove a workaround for ancient libevent versions.

2018-05-10 Thread nickm
commit 4218511ecd8a1facbd38d744b1bd518c05517988
Author: Nick Mathewson 
Date:   Wed May 9 12:38:50 2018 -0400

Remove a workaround for ancient libevent versions.

Libevent has accepted a const timeval argument to event_add() for a
very long time now.
---
 src/common/compat_libevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index cf3b7298c..56ee682fd 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -269,7 +269,7 @@ periodic_timer_launch(periodic_timer_t *timer, const struct 
timeval *tv)
   tor_assert(timer);
   if (event_pending(timer->ev, EV_TIMEOUT, NULL))
 return;
-  event_add(timer->ev, (struct timeval *)tv); /*drop const for old libevent*/
+  event_add(timer->ev, tv);
 }
 
 /**



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'ticket26063_squashed'

2018-05-10 Thread nickm
commit 1eede00a4bd9a7de2acf77393f2fc57aa3196d08
Merge: beca6a585 8b4cf7771
Author: Nick Mathewson 
Date:   Thu May 10 09:13:28 2018 -0400

Merge branch 'ticket26063_squashed'

 changes/ticket26063  |  5 +++
 src/common/compat_libevent.c | 31 ++-
 src/common/compat_libevent.h |  2 +
 src/or/config.c  |  9 +++--
 src/or/connection.c  | 12 +++---
 src/or/connection_edge.c |  1 +
 src/or/control.c | 89 ++--
 src/or/control.h |  3 ++
 src/or/dirserv.c |  2 +-
 src/or/hibernate.c   | 17 -
 src/or/hibernate.h   |  1 +
 src/or/main.c| 67 +
 src/or/main.h|  1 +
 src/or/router.c  | 18 +++--
 src/or/router.h  |  1 +
 15 files changed, 208 insertions(+), 51 deletions(-)

diff --cc src/or/hibernate.c
index b83167d20,24479cff9..d7d259470
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@@ -1187,18 -1137,10 +1200,20 @@@ on_hibernate_state_change(hibernate_sta
if (prev_state != HIBERNATE_STATE_INITIAL) {
  rescan_periodic_events(get_options());
}
+ 
+   reschedule_per_second_timer();
  }
  
 +/** Free all resources held by the accounting module */
 +void
 +accounting_free_all(void)
 +{
 +  mainloop_event_free(wakeup_event);
 +  hibernate_state = HIBERNATE_STATE_INITIAL;
 +  hibernate_end_time = 0;
 +  shutdown_time = 0;
 +}
 +
  #ifdef TOR_UNIT_TESTS
  /**
   * Manually change the hibernation state.  Private; used only by the unit
diff --cc src/or/main.c
index 69e7f05b1,0493596aa..6cb9b6249
--- a/src/or/main.c
+++ b/src/or/main.c
@@@ -2495,70 -2491,40 +2491,100 @@@ hs_service_callback(time_t now, const o
  
  /** Timer: used to invoke second_elapsed_callback() once per second. */
  static periodic_timer_t *second_timer = NULL;
+ 
+ /**
+  * Enable or disable the per-second timer as appropriate, creating it if
+  * necessary.
+  */
+ void
+ reschedule_per_second_timer(void)
+ {
+   struct timeval one_second;
+   one_second.tv_sec = 1;
+   one_second.tv_usec = 0;
+ 
+   if (! second_timer) {
+ second_timer = periodic_timer_new(tor_libevent_get_base(),
+   _second,
+   second_elapsed_callback,
+   NULL);
+ tor_assert(second_timer);
+   }
+ 
+   const bool run_per_second_events =
+ control_any_per_second_event_enabled() || ! net_is_completely_disabled();
+ 
+   if (run_per_second_events) {
+ periodic_timer_launch(second_timer, _second);
+   } else {
+ periodic_timer_disable(second_timer);
+   }
+ }
+ 
 -/** Number of libevent errors in the last second: we die if we get too many. 
*/
 -static int n_libevent_errors = 0;
 -/** Last time that second_elapsed_callback was called. */
 +/** Last time that update_current_time was called. */
  static time_t current_second = 0;
 +/** Last time that update_current_time updated current_second. */
 +static monotime_coarse_t current_second_last_changed;
 +
 +/**
 + * Set the current time to "now", which should be the value returned by
 + * time().  Check for clock jumps and track the total number of seconds we
 + * have been running.
 + */
 +void
 +update_current_time(time_t now)
 +{
 +  if (PREDICT_LIKELY(now == current_second)) {
 +/* We call this function a lot.  Most frequently, the current second
 + * will not have changed, so we just return. */
 +return;
 +  }
 +
 +  const time_t seconds_elapsed = current_second ? (now - current_second) : 0;
 +
 +  /* Check the wall clock against the monotonic clock, so we can
 +   * better tell idleness from clock jumps and/or other shenanigans. */
 +  monotime_coarse_t last_updated;
 +  memcpy(_updated, _second_last_changed, sizeof(last_updated));
 +  monotime_coarse_get(_second_last_changed);
 +
 +  /** How much clock jumping do we tolerate? */
 +#define NUM_JUMPED_SECONDS_BEFORE_WARN 100
 +
 +  /** How much idleness do we tolerate? */
 +#define NUM_IDLE_SECONDS_BEFORE_WARN 3600
 +
 +  if (seconds_elapsed < -NUM_JUMPED_SECONDS_BEFORE_WARN) {
 +// moving back in time is always a bad sign.
 +circuit_note_clock_jumped(seconds_elapsed, false);
 +  } else if (seconds_elapsed >= NUM_JUMPED_SECONDS_BEFORE_WARN) {
 +/* Compare the monotonic clock to the result of time(). */
 +const int32_t monotime_msec_passed =
 +  monotime_coarse_diff_msec32(_updated,
 +  _second_last_changed);
 +const int monotime_sec_passed = monotime_msec_passed / 1000;
 +const int discrepancy = monotime_sec_passed - (int)seconds_elapsed;
 +/* If the monotonic clock deviates from time(NULL), we have a couple of
 + * possibilities.  On some systems, this means we have been suspended or
 + * sleeping.  Everywhere, it can mean that the wall-clock time has
 + * been changed -- for example, with 

[tor-commits] [tor/master] Enable/disable per-second callback as needed.

2018-05-10 Thread nickm
commit 8b4cf7771e869bea4550452ad2cf5634278e0e87
Author: Nick Mathewson 
Date:   Wed May 9 12:47:59 2018 -0400

Enable/disable per-second callback as needed.

There are three cases where this can happen: changes in our
controller events, changes in our DisableNetwork setting, and
changes in our hibernation state.

Closes ticket 26063.
---
 changes/ticket26063 | 5 +
 src/or/config.c | 3 +++
 src/or/control.c| 5 +
 src/or/hibernate.c  | 2 ++
 4 files changed, 15 insertions(+)

diff --git a/changes/ticket26063 b/changes/ticket26063
new file mode 100644
index 0..c11eb2d15
--- /dev/null
+++ b/changes/ticket26063
@@ -0,0 +1,5 @@
+  o Major features (CPU usage, mobile):
+- When Tor is disabled (via DisableNetwork or via hibernation), it
+  no longer needs to run any per-second events.  This change should
+  make it easier for mobile applications to disable Tor while the
+  device is sleeping, or Tor is not running.  Closes ticket 26063.
diff --git a/src/or/config.c b/src/or/config.c
index e695947f0..2cc28b6d7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2001,6 +2001,9 @@ options_act(const or_options_t *old_options)
 finish_daemon(options->DataDirectory);
   }
 
+  /* See whether we need to enable/disable our once-a-second timer. */
+  reschedule_per_second_timer();
+
   /* We want to reinit keys as needed before we do much of anything else:
  keys are important, and other things can depend on them. */
   if (transition_affects_workers ||
diff --git a/src/or/control.c b/src/or/control.c
index 44439b6d5..237a8572d 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -277,6 +277,7 @@ control_update_global_event_mask(void)
   smartlist_t *conns = get_connection_array();
   event_mask_t old_mask, new_mask;
   old_mask = global_event_mask;
+  int any_old_per_sec_events = control_any_per_second_event_enabled();
 
   global_event_mask = 0;
   SMARTLIST_FOREACH(conns, connection_t *, _conn,
@@ -316,6 +317,10 @@ control_update_global_event_mask(void)
 uint64_t r, w;
 control_get_bytes_rw_last_sec(, );
   }
+  if (any_old_per_sec_events != control_any_per_second_event_enabled()) {
+reschedule_per_second_timer();
+  }
+
 #undef NEWLY_ENABLED
 }
 
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index f73b0420d..24479cff9 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -1137,6 +1137,8 @@ on_hibernate_state_change(hibernate_state_t prev_state)
   if (prev_state != HIBERNATE_STATE_INITIAL) {
 rescan_periodic_events(get_options());
   }
+
+  reschedule_per_second_timer();
 }
 
 #ifdef TOR_UNIT_TESTS



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Use net_is_completely_disabled() in connection.c

2018-05-10 Thread nickm
commit fa7847e450ee9884eda6236b50ea0d59db3efaba
Author: Nick Mathewson 
Date:   Wed May 9 12:26:50 2018 -0400

Use net_is_completely_disabled() in connection.c

This fixes the  case that we had before, and also enforces the
rule that we won't open connections when we're in hard hibernation.
---
 src/or/connection.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/or/connection.c b/src/or/connection.c
index 9b7e15243..ddeffd1b4 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1762,13 +1762,13 @@ connection_connect_sockaddr,(connection_t *conn,
   tor_assert(sa);
   tor_assert(socket_error);
 
-  if (get_options()->DisableNetwork) { //  change this -NM.
-/* We should never even try to connect anyplace if DisableNetwork is set.
- * Warn if we do, and refuse to make the connection.
+  if (net_is_completely_disabled()) {
+/* We should never even try to connect anyplace if the network is
+ * completely shut off.
  *
- * We only check DisableNetwork here, not we_are_hibernating(), since
- * we'll still try to fulfill client requests sometimes in the latter case
- * (if it is soft hibernation) */
+ * (We don't check net_is_disabled() here, since we still sometimes
+ * want to open connections when we're in soft hibernation.)
+ */
 static ratelim_t disablenet_violated = RATELIM_INIT(30*60);
 *socket_error = SOCK_ERRNO(ENETUNREACH);
 log_fn_ratelim(_violated, LOG_WARN, LD_BUG,



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Give control.c responsibility for its own once-a-second events

2018-05-10 Thread nickm
commit 0c19ce7bdece5906e035e71d3fb682632c8bb9cb
Author: Nick Mathewson 
Date:   Mon May 7 17:41:54 2018 -0400

Give control.c responsibility for its own once-a-second events

Now it has a function that can tell the rest of Tor whether any
once-a-second controller item should fire, and a function to fire
all the once-a-second events.
---
 src/or/control.c | 71 
 src/or/control.h |  3 +++
 src/or/main.c| 19 ++-
 3 files changed, 76 insertions(+), 17 deletions(-)

diff --git a/src/or/control.c b/src/or/control.c
index 695f0779c..d653a520b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1,3 +1,4 @@
+
 /* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  * Copyright (c) 2007-2017, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
@@ -112,6 +113,10 @@ static int disable_log_messages = 0;
 #define EVENT_IS_INTERESTING(e) \
   (!! (global_event_mask & EVENT_MASK_(e)))
 
+/** Macro: true if any event from the bitfield 'e' is interesting. */
+#define ANY_EVENT_IS_INTERESTING(e) \
+  EVENT_IS_INTERESTING(e)
+
 /** If we're using cookie-type authentication, how long should our cookies be?
  */
 #define AUTHENTICATION_COOKIE_LEN 32
@@ -219,6 +224,7 @@ static void set_cached_network_liveness(int liveness);
 static void flush_queued_events_cb(mainloop_event_t *event, void *arg);
 
 static char * download_status_to_string(const download_status_t *dl);
+static void control_get_bytes_rw_last_sec(uint64_t *r, uint64_t *w);
 
 /** Given a control event code for a message event, return the corresponding
  * log severity. */
@@ -306,6 +312,10 @@ control_update_global_event_mask(void)
   if (NEWLY_ENABLED(EVENT_CIRC_BANDWIDTH_USED)) {
 clear_circ_bw_fields();
   }
+  if (NEWLY_ENABLED(EVENT_BANDWIDTH_USED)) {
+uint64_t r, w;
+control_get_bytes_rw_last_sec(, );
+  }
 #undef NEWLY_ENABLED
 }
 
@@ -355,6 +365,65 @@ control_event_is_interesting(int event)
   return EVENT_IS_INTERESTING(event);
 }
 
+/** Return true if any event that needs to fire once a second is enabled. */
+int
+control_any_per_second_event_enabled(void)
+{
+  return ANY_EVENT_IS_INTERESTING(
+  EVENT_BANDWIDTH_USED |
+  EVENT_CELL_STATS |
+  EVENT_CIRC_BANDWIDTH_USED |
+  EVENT_CONN_BW |
+  EVENT_STREAM_BANDWIDTH_USED
+  );
+}
+
+/* The value of 'get_bytes_read()' the previous time that
+ * control_get_bytes_rw_last_sec() as called. */
+static uint64_t stats_prev_n_read = 0;
+/* The value of 'get_bytes_written()' the previous time that
+ * control_get_bytes_rw_last_sec() as called. */
+static uint64_t stats_prev_n_written = 0;
+
+/**
+ * Set n_read and n_written to the total number of bytes read
+ * and written by Tor since the last call to this function.
+ *
+ * Call this only from the main thread.
+ */
+static void
+control_get_bytes_rw_last_sec(uint64_t *n_read,
+  uint64_t *n_written)
+{
+  const uint64_t stats_n_bytes_read = get_bytes_read();
+  const uint64_t stats_n_bytes_written = get_bytes_written();
+
+  *n_read = stats_n_bytes_read - stats_prev_n_read;
+  *n_written = stats_n_bytes_written - stats_prev_n_written;
+  stats_prev_n_read = stats_n_bytes_read;
+  stats_prev_n_written = stats_n_bytes_written;
+}
+
+/**
+ * Run all the controller events (if any) that are scheduled to trigger once
+ * per second.
+ */
+void
+control_per_second_events(void)
+{
+  if (!control_any_per_second_event_enabled())
+return;
+
+  uint64_t bytes_read, bytes_written;
+  control_get_bytes_rw_last_sec(_read, _written);
+  control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);
+
+  control_event_stream_bandwidth_used();
+  control_event_conn_bandwidth_used();
+  control_event_circ_bandwidth_used();
+  control_event_circuit_cell_stats();
+}
+
 /** Append a NUL-terminated string s to the end of
  * conn-\>outbuf.
  */
@@ -7609,6 +7678,8 @@ control_free_all(void)
 {
   smartlist_t *queued_events = NULL;
 
+  stats_prev_n_read = stats_prev_n_written = 0;
+
   if (authentication_cookie) /* Free the auth cookie */
 tor_free(authentication_cookie);
   if (detached_onion_services) { /* Free the detached onion services */
diff --git a/src/or/control.h b/src/or/control.h
index 7f8a0bdb5..92cbf866d 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -40,6 +40,9 @@ int connection_control_process_inbuf(control_connection_t 
*conn);
 #define EVENT_NS 0x000F
 int control_event_is_interesting(int event);
 
+void control_per_second_events(void);
+int control_any_per_second_event_enabled(void);
+
 int control_event_circuit_status(origin_circuit_t *circ,
  circuit_status_event_t e, int reason);
 int control_event_circuit_purpose_changed(origin_circuit_t *circ,
diff --git a/src/or/main.c b/src/or/main.c
index c3505a2d9..8929931eb 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -163,11 +163,6 @@ token_bucket_rw_t 

[tor-commits] [tor/master] Comment-only fix: annotate we_are_hibernating() usage

2018-05-10 Thread nickm
commit c0feb698a0ab8574019d23cbd3060eb0513489c4
Author: Nick Mathewson 
Date:   Wed May 9 12:18:04 2018 -0400

Comment-only fix: annotate we_are_hibernating() usage

Everywhere we use we_are_hibernating(), remind the reader what it
means.

(Also, add an  to note a DisableNetwork usage to change later.)
---
 src/or/config.c  | 6 +++---
 src/or/connection.c  | 2 +-
 src/or/connection_edge.c | 1 +
 src/or/control.c | 2 ++
 src/or/dirserv.c | 2 +-
 src/or/main.c| 3 ++-
 src/or/router.c  | 3 +++
 7 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 9af613e93..e695947f0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1449,9 +1449,9 @@ options_act_reversible(const or_options_t *old_options, 
char **msg)
 consider_hibernation(time(NULL));
 
 /* Launch the listeners.  (We do this before we setuid, so we can bind to
- * ports under 1024.)  We don't want to rebind if we're hibernating. If
- * networking is disabled, this will close all but the control listeners,
- * but disable those. */
+ * ports under 1024.)  We don't want to rebind if we're hibernating or
+ * shutting down. If networking is disabled, this will close all but the
+ * control listeners, but disable those. */
 if (!we_are_hibernating()) {
   if (retry_all_listeners(replaced_listeners, new_listeners,
   options->DisableNetwork) < 0) {
diff --git a/src/or/connection.c b/src/or/connection.c
index 4361e1ca0..9b7e15243 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1762,7 +1762,7 @@ connection_connect_sockaddr,(connection_t *conn,
   tor_assert(sa);
   tor_assert(socket_error);
 
-  if (get_options()->DisableNetwork) {
+  if (get_options()->DisableNetwork) { //  change this -NM.
 /* We should never even try to connect anyplace if DisableNetwork is set.
  * Warn if we do, and refuse to make the connection.
  *
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 5ae1538bf..28e18aa85 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -3537,6 +3537,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
   n_stream->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
   /* default to failed, change in dns_resolve if it turns out not to fail */
 
+  /* If we're hibernating or shutting down, we refuse to open new streams. */
   if (we_are_hibernating()) {
 relay_send_end_cell_from_edge(rh.stream_id, circ,
   END_STREAM_REASON_HIBERNATING, NULL);
diff --git a/src/or/control.c b/src/or/control.c
index d653a520b..44439b6d5 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -7107,6 +7107,8 @@ control_event_bootstrap_problem(const char *warn, const 
char *reason,
   if (bootstrap_problems >= BOOTSTRAP_PROBLEM_THRESHOLD)
 dowarn = 1;
 
+  /* Don't warn about our bootstrapping status if we are hibernating or
+   * shutting down. */
   if (we_are_hibernating())
 dowarn = 0;
 
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index bfcec6e10..c01234e0b 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -955,7 +955,7 @@ dirserv_set_router_is_running(routerinfo_t *router, time_t 
now)
   tor_assert(node);
 
   if (router_is_me(router)) {
-/* We always know if we are down ourselves. */
+/* We always know if we are shutting down or hibernating ourselves. */
 answer = ! we_are_hibernating();
   } else if (router->is_hibernating &&
  (router->cache_info.published_on +
diff --git a/src/or/main.c b/src/or/main.c
index 8929931eb..682ec29ab 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1253,7 +1253,8 @@ run_connection_housekeeping(int i, time_t now)
   } else if (we_are_hibernating() &&
  ! have_any_circuits &&
  !connection_get_outbuf_len(conn)) {
-/* We're hibernating, there's no circuits, and nothing to flush.*/
+/* We're hibernating or shutting down, there's no circuits, and nothing to
+ * flush.*/
 log_info(LD_OR,"Expiring non-used OR connection to fd %d (%s:%d) "
  "[Hibernating or exiting].",
  (int)conn->s,conn->address, conn->port);
diff --git a/src/or/router.c b/src/or/router.c
index 996a28a91..71b292a67 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2268,6 +2268,7 @@ router_build_fresh_descriptor(routerinfo_t **r, 
extrainfo_t **e)
   /* and compute ri->bandwidthburst similarly */
   ri->bandwidthburst = get_effective_bwburst(options);
 
+  /* Report bandwidth, unless we're hibernating or shutting down */
   ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
 
   if (dns_seems_to_be_broken() || has_dns_init_failed()) {
@@ -2538,6 +2539,8 @@ check_descriptor_bandwidth_changed(time_t now)
 return;
 
   prev = router_get_my_routerinfo()->bandwidthcapacity;
+  /* Consider ourselves to have zero bandwidth if 

[tor-commits] [tor/master] Add functions to enable/disable periodic_event_t objects.

2018-05-10 Thread nickm
commit 80f582ae1841d262edd7f55260f350d949294c0c
Author: Nick Mathewson 
Date:   Wed May 9 12:37:47 2018 -0400

Add functions to enable/disable periodic_event_t objects.
---
 src/common/compat_libevent.c | 31 ++-
 src/common/compat_libevent.h |  2 ++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index fa00fb836..cf3b7298c 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -253,10 +253,39 @@ periodic_timer_new(struct event_base *base,
   }
   timer->cb = cb;
   timer->data = data;
-  event_add(timer->ev, (struct timeval *)tv); /*drop const for old libevent*/
+  periodic_timer_launch(timer, tv);
   return timer;
 }
 
+/**
+ * Launch the timer timer to run at tv from now, and every
+ * tv thereafter.
+ *
+ * If the timer is already enabled, this function does nothing.
+ */
+void
+periodic_timer_launch(periodic_timer_t *timer, const struct timeval *tv)
+{
+  tor_assert(timer);
+  if (event_pending(timer->ev, EV_TIMEOUT, NULL))
+return;
+  event_add(timer->ev, (struct timeval *)tv); /*drop const for old libevent*/
+}
+
+/**
+ * Disable the provided timer, but do not free it.
+ *
+ * You can reenable the same timer later with periodic_timer_launch.
+ *
+ * If the timer is already disabled, this function does nothing.
+ */
+void
+periodic_timer_disable(periodic_timer_t *timer)
+{
+  tor_assert(timer);
+  event_del(timer->ev);
+}
+
 /** Stop and free a periodic timer */
 void
 periodic_timer_free_(periodic_timer_t *timer)
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index e2747860a..286a26812 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -31,6 +31,8 @@ periodic_timer_t *periodic_timer_new(struct event_base *base,
  void (*cb)(periodic_timer_t *timer, void *data),
  void *data);
 void periodic_timer_free_(periodic_timer_t *);
+void periodic_timer_launch(periodic_timer_t *, const struct timeval *tv);
+void periodic_timer_disable(periodic_timer_t *);
 #define periodic_timer_free(t) \
   FREE_AND_NULL(periodic_timer_t, periodic_timer_free_, (t))
 



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Add a new net_is_completely_disabled() function

2018-05-10 Thread nickm
commit 7595eae52ace0d2e0110e3d0471d4a5ca0c99ce9
Author: Nick Mathewson 
Date:   Wed May 9 12:21:08 2018 -0400

Add a new net_is_completely_disabled() function
---
 src/or/router.c | 15 ---
 src/or/router.h |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/or/router.c b/src/or/router.c
index 71b292a67..07abf1f8d 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1599,15 +1599,24 @@ router_perform_bandwidth_test(int num_circs, time_t now)
   }
 }
 
-/** Return true iff our network is in some sense disabled: either we're
- * hibernating, entering hibernation, or the network is turned off with
- * DisableNetwork. */
+/** Return true iff our network is in some sense disabled or shutting down:
+ * either we're hibernating, entering hibernation, or the network is turned
+ * off with DisableNetwork. */
 int
 net_is_disabled(void)
 {
   return get_options()->DisableNetwork || we_are_hibernating();
 }
 
+/** Return true iff our network is in some sense "completely disabled" either
+ * we're fully hibernating or the network is turned off with
+ * DisableNetwork. */
+int
+net_is_completely_disabled(void)
+{
+  return get_options()->DisableNetwork || we_are_fully_hibernating();
+}
+
 /** Return true iff we believe ourselves to be an authoritative
  * directory server.
  */
diff --git a/src/or/router.h b/src/or/router.h
index 03eca9c65..0db2c1cfb 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -53,6 +53,7 @@ void router_dirport_found_reachable(void);
 void router_perform_bandwidth_test(int num_circs, time_t now);
 
 int net_is_disabled(void);
+int net_is_completely_disabled(void);
 
 int authdir_mode(const or_options_t *options);
 int authdir_mode_handles_descs(const or_options_t *options, int purpose);



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Add a macro to simplify control_update_global_event_mask().

2018-05-10 Thread nickm
commit 79b38081e985d65cfd08236d2eb42a87cc59a786
Author: Nick Mathewson 
Date:   Mon May 7 16:35:52 2018 -0400

Add a macro to simplify control_update_global_event_mask().
---
 src/or/control.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/or/control.c b/src/or/control.c
index 93b204f9a..695f0779c 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -288,10 +288,13 @@ control_update_global_event_mask(void)
* we want to hear...*/
   control_adjust_event_log_severity();
 
+  /* Macro: true if ev was false before and is true now. */
+#define NEWLY_ENABLED(ev) \
+  (! (old_mask & (ev)) && (new_mask & (ev)))
+
   /* ...then, if we've started logging stream or circ bw, clear the
* appropriate fields. */
-  if (! (old_mask & EVENT_STREAM_BANDWIDTH_USED) &&
-  (new_mask & EVENT_STREAM_BANDWIDTH_USED)) {
+  if (NEWLY_ENABLED(EVENT_STREAM_BANDWIDTH_USED)) {
 SMARTLIST_FOREACH(conns, connection_t *, conn,
 {
   if (conn->type == CONN_TYPE_AP) {
@@ -300,10 +303,10 @@ control_update_global_event_mask(void)
   }
 });
   }
-  if (! (old_mask & EVENT_CIRC_BANDWIDTH_USED) &&
-  (new_mask & EVENT_CIRC_BANDWIDTH_USED)) {
+  if (NEWLY_ENABLED(EVENT_CIRC_BANDWIDTH_USED)) {
 clear_circ_bw_fields();
   }
+#undef NEWLY_ENABLED
 }
 
 /** Adjust the log severities that result in control_event_logmsg being called



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Add we_are_fully_hibernating() to distinguish hibernation states

2018-05-10 Thread nickm
commit 50328533e3595b9cc2d3fc72f81f56572c9e732d
Author: Nick Mathewson 
Date:   Wed May 9 12:11:14 2018 -0400

Add we_are_fully_hibernating() to distinguish hibernation states

We want to tell "shut down" from "shutting down".
---
 src/or/hibernate.c | 15 ++-
 src/or/hibernate.h |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 98f32adb1..f73b0420d 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -877,13 +877,26 @@ hibernate_begin_shutdown(void)
   hibernate_begin(HIBERNATE_STATE_EXITING, time(NULL));
 }
 
-/** Return true iff we are currently hibernating. */
+/**
+ * Return true iff we are currently hibernating -- that is, if we are in
+ * any non-live state.
+ */
 MOCK_IMPL(int,
 we_are_hibernating,(void))
 {
   return hibernate_state != HIBERNATE_STATE_LIVE;
 }
 
+/**
+ * Return true iff we are currently _fully_ hibernating -- that is, if we are
+ * in a state where we expect to handle no network activity at all.
+ */
+MOCK_IMPL(int,
+we_are_fully_hibernating,(void))
+{
+  return hibernate_state == HIBERNATE_STATE_DORMANT;
+}
+
 /** If we aren't currently dormant, close all connections and become
  * dormant. */
 static void
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 85fb42864..84558bb2f 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -25,6 +25,7 @@ void accounting_add_bytes(size_t n_read, size_t n_written, 
int seconds);
 int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
 void hibernate_begin_shutdown(void);
 MOCK_DECL(int, we_are_hibernating, (void));
+MOCK_DECL(int, we_are_fully_hibernating,(void));
 void consider_hibernation(time_t now);
 int getinfo_helper_accounting(control_connection_t *conn,
   const char *question, char **answer,



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'ticket26064'

2018-05-10 Thread nickm
commit beca6a585c5cd594333ae07b0ae3326188f9d67c
Merge: a4a7939ae a1a7ebfb8
Author: Nick Mathewson 
Date:   Thu May 10 09:05:15 2018 -0400

Merge branch 'ticket26064'

 changes/ticket26064 |  5 
 src/or/hibernate.c  | 73 +
 src/or/hibernate.h  |  1 +
 src/or/main.c   |  2 ++
 4 files changed, 81 insertions(+)

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Give responsibility for waking up from DORMANT to a mainloop event

2018-05-10 Thread nickm
commit a1a7ebfb8dbb9b104771e99571b6a60c70ee1dbe
Author: Nick Mathewson 
Date:   Wed May 9 13:41:04 2018 -0400

Give responsibility for waking up from DORMANT to a mainloop event

Closes ticket 26064.
---
 changes/ticket26064 |  5 
 src/or/hibernate.c  | 73 +
 src/or/hibernate.h  |  1 +
 src/or/main.c   |  2 ++
 4 files changed, 81 insertions(+)

diff --git a/changes/ticket26064 b/changes/ticket26064
new file mode 100644
index 0..6efb8a483
--- /dev/null
+++ b/changes/ticket26064
@@ -0,0 +1,5 @@
+  o Minor features (accounting):
+- When we become dormant, use a scheduled event to wake up at the right
+  time.  Previously, we would use the per-second timer to check whether
+  to wake up, but we no longer have any per-second timers enabled when
+  the network is disabled. Closes ticket 26064.
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 98f32adb1..b83167d20 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -52,6 +52,10 @@ static time_t hibernate_end_time = 0;
  * we aren't shutting down. */
 static time_t shutdown_time = 0;
 
+/** A timed event that we'll use when it's time to wake up from
+ * hibernation. */
+static mainloop_event_t *wakeup_event = NULL;
+
 /** Possible accounting periods. */
 typedef enum {
   UNIT_MONTH=1, UNIT_WEEK=2, UNIT_DAY=3,
@@ -131,6 +135,8 @@ static time_t start_of_accounting_period_after(time_t now);
 static time_t start_of_accounting_period_containing(time_t now);
 static void accounting_set_wakeup_time(void);
 static void on_hibernate_state_change(hibernate_state_t prev_state);
+static void hibernate_schedule_wakeup_event(time_t now, time_t end_time);
+static void wakeup_event_callback(mainloop_event_t *ev, void *data);
 
 /**
  * Return the human-readable name for the hibernation state state
@@ -936,6 +942,63 @@ hibernate_go_dormant(time_t now)
 
   or_state_mark_dirty(get_or_state(),
   get_options()->AvoidDiskWrites ? now+600 : 0);
+
+  hibernate_schedule_wakeup_event(now, hibernate_end_time);
+}
+
+/**
+ * Schedule a mainloop event at end_time to wake up from a dormant
+ * state.  We can't rely on this happening from second_elapsed_callback,
+ * since second_elapsed_callback will be shut down when we're dormant.
+ *
+ * (Note that We might immediately go back to sleep after we set the next
+ * wakeup time.)
+ */
+static void
+hibernate_schedule_wakeup_event(time_t now, time_t end_time)
+{
+  struct timeval delay = { 0, 0 };
+
+  if (now >= end_time) {
+// In these cases we always wait at least a second, to avoid running
+// the callback in a tight loop.
+delay.tv_sec = 1;
+  } else {
+delay.tv_sec = (end_time - now);
+  }
+
+  if (!wakeup_event) {
+wakeup_event = mainloop_event_postloop_new(wakeup_event_callback, NULL);
+  }
+
+  mainloop_event_schedule(wakeup_event, );
+}
+
+/**
+ * Called at the end of the interval, or at the wakeup time of the current
+ * interval, to exit the dormant state.
+ **/
+static void
+wakeup_event_callback(mainloop_event_t *ev, void *data)
+{
+  (void) ev;
+  (void) data;
+
+  const time_t now = time(NULL);
+  accounting_run_housekeeping(now);
+  consider_hibernation(now);
+  if (hibernate_state != HIBERNATE_STATE_DORMANT) {
+/* We woke up, so everything's great here */
+return;
+  }
+
+  /* We're still dormant. */
+  if (now < interval_wakeup_time)
+hibernate_end_time = interval_wakeup_time;
+  else
+hibernate_end_time = interval_end_time;
+
+  hibernate_schedule_wakeup_event(now, hibernate_end_time);
 }
 
 /** Called when hibernate_end_time has arrived. */
@@ -1126,6 +1189,16 @@ on_hibernate_state_change(hibernate_state_t prev_state)
   }
 }
 
+/** Free all resources held by the accounting module */
+void
+accounting_free_all(void)
+{
+  mainloop_event_free(wakeup_event);
+  hibernate_state = HIBERNATE_STATE_INITIAL;
+  hibernate_end_time = 0;
+  shutdown_time = 0;
+}
+
 #ifdef TOR_UNIT_TESTS
 /**
  * Manually change the hibernation state.  Private; used only by the unit
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 85fb42864..4bbda6694 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -30,6 +30,7 @@ int getinfo_helper_accounting(control_connection_t *conn,
   const char *question, char **answer,
   const char **errmsg);
 uint64_t get_accounting_max_total(void);
+void accounting_free_all(void);
 
 #ifdef HIBERNATE_PRIVATE
 /** Possible values of hibernate_state */
diff --git a/src/or/main.c b/src/or/main.c
index c3505a2d9..9cbe5c8d9 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3618,6 +3618,8 @@ tor_free_all(int postfork)
   hs_free_all();
   dos_free_all();
   circuitmux_ewma_free_all();
+  accounting_free_all();
+
   if (!postfork) {
 config_free_all();
 or_state_free_all();



___
tor-commits mailing list

[tor-commits] [translation/support-topics_completed] Update translations for support-topics_completed

2018-05-10 Thread translation
commit ce6577a68fc715f1ea3af18e29a66b92ce512338
Author: Translation commit bot 
Date:   Thu May 10 12:49:42 2018 +

Update translations for support-topics_completed
---
 id.json | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/id.json b/id.json
index 946d325b3..2ff7ae3ef 100644
--- a/id.json
+++ b/id.json
@@ -5,18 +5,18 @@
"label": "Most Frequently Asked Questions"
 },
 "tbb": {
-   "path": "#tor-browser",
-   "control": "tor-browser",
+   "path": "#tbb",
+   "control": "tbb",
"label": "Peramban Tor"
 },
 "tormessenger": {
-   "path": "#tor-messenger",
-   "control": "tor-messenger",
+   "path": "#tormessenger",
+   "control": "tormessenger",
"label": "Tor Messenger"
 },
 "tormobile": {
-   "path": "#tor-mobile",
-   "control": "tor-mobile",
+   "path": "#tormobile",
+   "control": "tormobile",
"label": "Tor Mobile"
 },
 "gettor": {
@@ -25,8 +25,8 @@
"label": "GetTor"
 },
 "connecting": {
-   "path": "#connecting-to-tor",
-   "control": "connecting-to-tor",
+   "path": "#connectingtotor",
+   "control": "connectingtotor",
"label": "Terhubung ke Tor"
 },
 "censorship": {
@@ -45,13 +45,13 @@
"label": "Operator"
 },
 "onionservices": {
-   "path": "#onion-services",
-   "control": "onion-services",
+   "path": "#onionservices",
+   "control": "onionservices",
"label": "Layanan Onion"
 },
-"miscellaneus": {
-   "path": "#miscellaneus",
-   "control": "miscellaneus",
+"misc": {
+   "path": "#misc",
+   "control": "lain-lain",
"label": "Lain-lain"
 }
 }

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [translation/support-tbb] Update translations for support-tbb

2018-05-10 Thread translation
commit b46102b8cd50959e5523e6223b65a6c2cbc2c2ab
Author: Translation commit bot 
Date:   Thu May 10 12:49:30 2018 +

Update translations for support-tbb
---
 id.json | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/id.json b/id.json
index 73dbcf5e9..600ae0101 100644
--- a/id.json
+++ b/id.json
@@ -3,7 +3,7 @@
"id": "#tbb-1",
"control": "tbb-1",
"title": "Apa masalah-masalah paling umum pada versi stabil termutakhir 
di Tor Browser?",
-   "description": "Setiap kami merilis peramban Tor 
Browser stabil terbaru, kami membuat posting blog yang menjelaskan fitur-fitur 
terbaru dan masalah yang diketahui. Jika Anda mengalami masalah dengan peramban 
Tor Browser setelah melakukan pembaruan, silakan lihat ​https://blog.torproject.org\;>https://blog.torproject.orgapakah
 masalah yang Anda alami terdaftar di sana."
+   "description": "Setiap kami merilis Tor Browser 
stabil terbaru, kami membuat posting blog yang menjelaskan fitur-fitur terbaru 
dan masalah yang diketahui. Jika Anda mengalami masalah dengan Tor Browser 
setelah melakukan pembaruan, silakan lihat ​https://blog.torproject.org\;>https://blog.torproject.orgapakah
 masalah yang Anda alami terdaftar di sana."
 },
 "tbb-2": {
"id": "#tbb-2",
@@ -45,7 +45,7 @@
"id": "#tbb-7-1",
"control": "tbb-7-1",
"title": "Saya mengalami masalah ketika menggunakan fitur-fitur di 
Facebook, Twitter atau situs web lain jika menggunakan Tor Browser. ",
-   "description": "Sometimes Javascript-heavy websites 
can have functional issues over Tor Browser. The simplest fix is to click on 
the \"onion menu,\" then click on the security slider. Set your security to 
\"low.\""
+   "description": "Kadang situs web yang menggunakan 
Javascript dengan banyak akan mendapat masalah ketika diakses dengan Tor 
Browser.  Cara paling sederhana untuk mengatasi hal ini adalah klik \"Onion 
Menu\" lalu klik security.  Setel tingkat keamanan menjadi \"rendah\"."
 },
 "tbb-8": {
"id": "#tbb-8",
@@ -75,7 +75,7 @@
"id": "#tbb-12",
"control": "tbb-12",
"title": "Apakah saya dapat menggunakan flash di Tor Browser?",
-   "description": "Flash is disabled in Tor Browser, and 
we recommend you do not enable it. We don’t think Flash is safe to use in any 
browser — it's a very insecure piece of software that can easily compromise 
your privacy or serve you malware. Fortunately, most websites, devices, and 
other browsers are moving away from the use of Flash."
+   "description": "Flash dinonaktifkan di Tor Browser, 
dan kami menyarankan Anda untuk tidak mengaktifkannya. Menurut kami, Flash 
tidak aman digunakan di peramban apa pun — Flash adalah software yang sangat 
tidak aman yang dengan sangat mudah menghilangkan privasi Anda atau memberikan 
malware. Untungnya sebagian besar situs web, alat, dan peramban lain sudah 
tidak lagi menggunakan Flash."
 },
 "tbb-13": {
"id": "#tbb-13",
@@ -105,7 +105,7 @@
"id": "#tbb-17",
"control": "tbb-17",
"title": "Apakah aman untuk menjalankan Tor Browser dan peramban lain 
dalam waktu bersamaan?",
-   "description": "If you run Tor Browser and another 
browser at the same time, it won't affect Tor's performance or privacy 
properties. However, be aware that your other browser is not keeping your 
activity private, and you may forget and accidentally use that non-private 
browser to do something that you intended to do in Tor Browser."
+   "description": "Jika Anda menjalankan Tor Browser dan 
peramban lain secara bersamaan, kinarja Tor  atau privasi tidak akan 
terpengaruh. Namun, sadarlah bahwa peramban lain tersebut tidak membuat 
kegiatan Anda menjadi privat, dan Anda mungkin akan lupa lalu tidak sengaja 
menggunakan peramban tadi untuk melakukan sesuatu yang Anda ingin lakukan 
dengan Tor Browser."
 },  
 "tbb-18": {
"id": "#tbb-18",
@@ -129,7 +129,7 @@
"id": "#tbb-21",
"control": "tbb-21",
"title": "Bagaimana cara melihat pesan log di Tor Browser?",
-   "description": "Click the button labelled \"Copy Tor 
Log To Clipboard\" that appears in the dialog window when Tor Browser is first 
connecting to the network. If Tor Browser is already open, click on the 
Torbutton icon (the small green onion at the top-left of the screen), then 
\"Open Network Settings\", then \"Copy Tor Log To Clipboard.\". Once you have 
copied the log, you will be able to paste it into a text editor or email 
client."
+   "description": "Klik tombol bernama \"Copy Tor Log To 
Clipboard\" yang muncul di jendela ketika Tor Browser pertama kali terhubung ke 
jaringan. Jika Tor Browser sudah buka, kik  ikon Torbutton (gambar bawang kecil 
hijau di kiri atas layar), lalu klik \"Open Network Settings\", dan klik \"Copy 
Tor Log To Clipboard.\". Setelah log tersebut di-copy,  paste ke text editor 

[tor-commits] [translation/support-topics] Update translations for support-topics

2018-05-10 Thread translation
commit ac8a0416296db456bbb7dd9e26e3fbf143e39096
Author: Translation commit bot 
Date:   Thu May 10 12:49:38 2018 +

Update translations for support-topics
---
 id.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/id.json b/id.json
index 46516ac86..2ff7ae3ef 100644
--- a/id.json
+++ b/id.json
@@ -51,7 +51,7 @@
 },
 "misc": {
"path": "#misc",
-   "control": "misc",
-   "label": "Misc"
+   "control": "lain-lain",
+   "label": "Lain-lain"
 }
 }

___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


  1   2   >