[tor-commits] [tor/master] Explain why we use raw_free with getdelim result.

2018-07-10 Thread nickm
commit 391ef5e42cc79982a28aaaf22e9f9b255f6910d3
Author: Nick Mathewson 
Date:   Tue Jul 10 20:16:37 2018 -0400

Explain why we use raw_free with getdelim result.
---
 src/feature/dircache/dirserv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c
index 57de6ab8e..1500467ec 100644
--- a/src/feature/dircache/dirserv.c
+++ b/src/feature/dircache/dirserv.c
@@ -2682,8 +2682,10 @@ dirserv_read_measured_bandwidths(const char *from_file,
   rv = 0;
 
  err:
-  if (line)
+  if (line) {
+// we need to raw_free this buffer because we got it from tor_getdelim()
 raw_free(line);
+  }
   if (fp)
 fclose(fp);
   return rv;



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


[tor-commits] [tor/master] Integrate getdelim() and getline() support into Tor.

2018-07-10 Thread nickm
commit b04d719c1067dd1cf9b48295f1d0e7ed5adb7255
Author: Nick Mathewson 
Date:   Tue Jul 10 10:23:29 2018 -0400

Integrate getdelim() and getline() support into Tor.
---
 configure.ac|  2 ++
 src/ext/getdelim.c  | 16 ++--
 src/lib/fs/.may_include |  3 +++
 src/lib/fs/files.c  |  4 
 src/lib/fs/files.h  | 34 ++
 5 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 296591f02..ff03cf10e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -585,7 +585,9 @@ AC_CHECK_FUNCS(
 ftime \
 get_current_dir_name \
 getaddrinfo \
+   getdelim \
 getifaddrs \
+   getline \
 getpass \
 getrlimit \
 gettimeofday \
diff --git a/src/ext/getdelim.c b/src/ext/getdelim.c
index 60df7e1b6..8254103ff 100644
--- a/src/ext/getdelim.c
+++ b/src/ext/getdelim.c
@@ -30,21 +30,19 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include 
-#include 
-#include 
-
-#if !HAVE_GETDELIM
+#ifndef BUFSIZ
+#define BUFSIZ 512
+#endif
 
 ssize_t
-getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
+compat_getdelim_(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
 {
char *ptr, *eptr;
 
 
if (*buf == NULL || *bufsiz == 0) {
*bufsiz = BUFSIZ;
-   if ((*buf = malloc(*bufsiz)) == NULL)
+   if ((*buf = raw_malloc(*bufsiz)) == NULL)
return -1;
}
 
@@ -69,7 +67,7 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
char *nbuf;
size_t nbufsiz = *bufsiz * 2;
ssize_t d = ptr - *buf;
-   if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
+   if ((nbuf = raw_realloc(*buf, nbufsiz)) == NULL)
return -1;
*buf = nbuf;
*bufsiz = nbufsiz;
@@ -78,5 +76,3 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
}
}
 }
-
-#endif
diff --git a/src/lib/fs/.may_include b/src/lib/fs/.may_include
index 6c9ce6ca0..b1e49fc89 100644
--- a/src/lib/fs/.may_include
+++ b/src/lib/fs/.may_include
@@ -1,4 +1,7 @@
 orconfig.h
+
+ext/getdelim.c
+
 lib/cc/*.h
 lib/container/*.h
 lib/encoding/*.h
diff --git a/src/lib/fs/files.c b/src/lib/fs/files.c
index 4e0a398ba..e93d36d86 100644
--- a/src/lib/fs/files.c
+++ b/src/lib/fs/files.c
@@ -715,3 +715,7 @@ read_file_to_str, (const char *filename, int flags, struct 
stat *stat_out))
 
   return string;
 }
+
+#if !defined(HAVE_GETDELIM) || defined(TOR_UNIT_TESTS)
+#include "ext/getdelim.c"
+#endif
diff --git a/src/lib/fs/files.h b/src/lib/fs/files.h
index 5a12eb821..d219e3cf0 100644
--- a/src/lib/fs/files.h
+++ b/src/lib/fs/files.h
@@ -103,4 +103,38 @@ char *read_file_to_str_until_eof(int fd, size_t 
max_bytes_to_read,
  size_t *sz_out)
   ATTR_MALLOC;
 
+#if !defined(HAVE_GETDELIM) || defined(TOR_UNIT_TESTS)
+ssize_t compat_getdelim_(char **lineptr, size_t *n, int delim, FILE *stream);
+#endif
+
+#ifdef HAVE_GETDELIM
+/**
+ * Cross-platform wrapper for getdelim(): behaves as the POSIX-standard
+ * getdelim() function.
+ *
+ * Note that this function will use the libc memory allocator -- so any memory
+ * passed to this function must come from raw_malloc(), and must be freed by
+ * raw_free() -- don't use tor_malloc() and tor_free() with this.
+ */
+#define tor_getdelim(lineptr, n, delim, stream) \
+  getdelim((lineptr), (n), (delim), (stream))
+#else
+#define tor_getdelim(lineptr, n, delim, stream) \
+  compat_getdelim_((lineptr), (n), (delim), (stream))
+#endif
+
+#ifdef HAVE_GETLINE
+/**
+ * Cross-platform wrapper for getline(): behaves as the POSIX-standard
+ * getline() function.
+ *
+ * See tor_getdelim() for usage notes.
+ */
+#define tor_getline(lineptr, n, stream) \
+  getline((lineptr), (n), (stream))
+#else
+#define tor_getline(lineptr, n, stream) \
+  tor_getdelim((lineptr), (n), '\n', (stream))
+#endif
+
 #endif



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


[tor-commits] [tor/master] Add the compatibility definition for getdelim.c from netbsd.

2018-07-10 Thread nickm
commit 1604c0fe0e5ce74538555c19a307ad38d0fca358
Author: Nick Mathewson 
Date:   Tue Jul 10 10:14:24 2018 -0400

Add the compatibility definition for getdelim.c from netbsd.

We shouldn't actually need this code nearly anywhere we build:
getdelim is POSIX, and mingw provides it.
---
 LICENSE| 30 
 src/ext/getdelim.c | 82 ++
 src/ext/include.am |  2 +-
 3 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/LICENSE b/LICENSE
index 057ae5765..9e2709aea 100644
--- a/LICENSE
+++ b/LICENSE
@@ -156,6 +156,36 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ===
+getdelim.c is distributed under this license:
+
+ Copyright (c) 2011 The NetBSD Foundation, Inc.
+ All rights reserved.
+
+ This code is derived from software contributed to The NetBSD Foundation
+ by Christos Zoulas.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+===
 src/config/geoip is licensed under the following license:
 
 OPEN DATA LICENSE (GeoLite Country and GeoLite City databases)
diff --git a/src/ext/getdelim.c b/src/ext/getdelim.c
new file mode 100644
index 0..60df7e1b6
--- /dev/null
+++ b/src/ext/getdelim.c
@@ -0,0 +1,82 @@
+/* $NetBSD: getdelim.c,v 1.2 2015/12/25 20:12:46 joerg Exp $   */
+/* NetBSD-src: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp*/
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+
+#if !HAVE_GETDELIM
+
+ssize_t
+getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
+{
+   char *ptr, *eptr;
+
+
+   if (*buf == NULL || *bufsiz == 0) {
+   *bufsiz = BUFSIZ;
+   if ((*buf = malloc(*bufsiz)) == NULL)
+   return -1;
+   }
+
+   for (ptr = *buf, eptr = *buf + *bufsiz;;) {
+   int c = fgetc(fp);
+   if (c == -1) {
+   if (feof(fp)) {
+   ssize_t diff = (ssize_t)(ptr - *buf);
+   if (diff != 

[tor-commits] [tor/master] Tabify lists in configure.ac

2018-07-10 Thread nickm
commit c4dd38e625a105a5d5d29242a8531da9677c98d8
Author: Nick Mathewson 
Date:   Tue Jul 10 20:15:23 2018 -0400

Tabify lists in configure.ac
---
 configure.ac | 200 +--
 1 file changed, 100 insertions(+), 100 deletions(-)

diff --git a/configure.ac b/configure.ac
index ff03cf10e..532476672 100644
--- a/configure.ac
+++ b/configure.ac
@@ -572,60 +572,60 @@ AM_CONDITIONAL(THREADS_WIN32, test "$bwin32" = "true")
 AM_CONDITIONAL(THREADS_PTHREADS, test "$bwin32" = "false")
 
 AC_CHECK_FUNCS(
-_NSGetEnviron \
+   _NSGetEnviron \
RtlSecureZeroMemory \
SecureZeroMemory \
-accept4 \
-backtrace \
-backtrace_symbols_fd \
+   accept4 \
+   backtrace \
+   backtrace_symbols_fd \
eventfd \
explicit_bzero \
timingsafe_memcmp \
-flock \
-ftime \
-get_current_dir_name \
-getaddrinfo \
+   flock \
+   ftime \
+   get_current_dir_name \
+   getaddrinfo \
getdelim \
-getifaddrs \
+   getifaddrs \
getline \
-getpass \
-getrlimit \
-gettimeofday \
-gmtime_r \
+   getpass \
+   getrlimit \
+   gettimeofday \
+   gmtime_r \
gnu_get_libc_version \
htonll \
-inet_aton \
-ioctl \
-issetugid \
-llround \
-localtime_r \
-lround \
+   inet_aton \
+   ioctl \
+   issetugid \
+   llround \
+   localtime_r \
+   lround \
mach_approximate_time \
-memmem \
-memset_s \
-mmap \
+   memmem \
+   memset_s \
+   mmap \
pipe \
pipe2 \
-prctl \
+   prctl \
readpassphrase \
-rint \
-sigaction \
-socketpair \
+   rint \
+   sigaction \
+   socketpair \
statvfs \
-strncasecmp \
-strcasecmp \
-strlcat \
-strlcpy \
+   strncasecmp \
+   strcasecmp \
+   strlcat \
+   strlcpy \
strnlen \
-strptime \
-strtok_r \
-strtoull \
-sysconf \
+   strptime \
+   strtok_r \
+   strtoull \
+   sysconf \
sysctl \
truncate \
-uname \
+   uname \
usleep \
-vasprintf \
+   vasprintf \
_vscprintf
 )
 
@@ -1367,57 +1367,57 @@ dnl Make sure to enable support for large off_t if 
available.
 AC_SYS_LARGEFILE
 
 AC_CHECK_HEADERS([errno.h \
-  fcntl.h \
-  signal.h \
-  string.h \
-  sys/capability.h \
-  sys/fcntl.h \
-  sys/stat.h \
-  sys/time.h \
-  sys/types.h \
-  time.h \
-  unistd.h \
-  arpa/inet.h \
-  crt_externs.h \
-  execinfo.h \
-  gnu/libc-version.h \
-  grp.h \
-  ifaddrs.h \
-  inttypes.h \
-  limits.h \
-  linux/types.h \
-  machine/limits.h \
-  malloc.h \
-  malloc/malloc.h \
-  malloc_np.h \
-  netdb.h \
-  netinet/in.h \
-  netinet/in6.h \
-  pwd.h \
-  readpassphrase.h \
-  stdatomic.h \
-  sys/eventfd.h \
-  sys/file.h \
-  sys/ioctl.h \
-  sys/limits.h \
-  sys/mman.h \
-  sys/param.h \
-  sys/prctl.h \
+ fcntl.h \
+ signal.h \
+ string.h \
+ sys/capability.h \
+ sys/fcntl.h \
+ sys/stat.h \
+ sys/time.h \
+ sys/types.h \
+ time.h \
+ unistd.h \
+ arpa/inet.h \
+ crt_externs.h \
+ execinfo.h \
+ gnu/libc-version.h \
+ grp.h \
+ ifaddrs.h \
+ inttypes.h \
+ limits.h \
+ linux/types.h \
+ machine/limits.h \
+ malloc.h \
+ malloc/malloc.h \
+ malloc_np.h \
+ netdb.h \
+ netinet/in.h \
+ netinet/in6.h \
+ pwd.h \
+ readpassphrase.h \
+ stdatomic.h \
+ sys/eventfd.h \
+ sys/file.h \
+ sys/ioctl.h \
+ sys/limits.h \
+ sys/mman.h \
+ sys/param.h \
+ sys/prctl.h \
  sys/random.h \
-  sys/resource.h \
-  sys/select.h \
-  sys/socket.h 

[tor-commits] [tor/master] Document compat_getdelim_.

2018-07-10 Thread nickm
commit c90961a9233e7287605886585503ee94d13a4592
Author: Nick Mathewson 
Date:   Tue Jul 10 20:18:20 2018 -0400

Document compat_getdelim_.
---
 src/lib/fs/files.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/lib/fs/files.h b/src/lib/fs/files.h
index d219e3cf0..2ee1b2014 100644
--- a/src/lib/fs/files.h
+++ b/src/lib/fs/files.h
@@ -104,6 +104,9 @@ char *read_file_to_str_until_eof(int fd, size_t 
max_bytes_to_read,
   ATTR_MALLOC;
 
 #if !defined(HAVE_GETDELIM) || defined(TOR_UNIT_TESTS)
+/** Internal back-end function to implement getdelim(): only exists when
+ * Tor is built for unit tests, or when Tor is built on an operating system
+ * without its own getdelim(). */
 ssize_t compat_getdelim_(char **lineptr, size_t *n, int delim, FILE *stream);
 #endif
 
@@ -112,6 +115,8 @@ ssize_t compat_getdelim_(char **lineptr, size_t *n, int 
delim, FILE *stream);
  * Cross-platform wrapper for getdelim(): behaves as the POSIX-standard
  * getdelim() function.
  *
+ * See `getdelim(3)` for more information.
+ *
  * Note that this function will use the libc memory allocator -- so any memory
  * passed to this function must come from raw_malloc(), and must be freed by
  * raw_free() -- don't use tor_malloc() and tor_free() with this.



___
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 'ticket26223'

2018-07-10 Thread nickm
commit 537092cdbb7f4be0e6d68f4e5d65ca2a403375f9
Merge: c08b7b10c c90961a92
Author: Nick Mathewson 
Date:   Tue Jul 10 20:18:28 2018 -0400

Merge branch 'ticket26223'

 LICENSE|  30 ++
 changes/bug26223   |   3 +
 configure.ac   | 202 +
 src/ext/getdelim.c |  78 
 src/ext/include.am |   2 +-
 src/feature/dircache/dirserv.c |  35 ---
 src/lib/fs/.may_include|   3 +
 src/lib/fs/files.c |   4 +
 src/lib/fs/files.h |  39 
 9 files changed, 280 insertions(+), 116 deletions(-)

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


[tor-commits] [tor/master] Refactor dirserv_read_measured_bandwidths to have a single exit point

2018-07-10 Thread nickm
commit 6574d4bd27471c30da934c4d8b82ecbe2b3eab7e
Author: Nick Mathewson 
Date:   Tue Jul 10 10:26:22 2018 -0400

Refactor dirserv_read_measured_bandwidths to have a single exit point
---
 src/feature/dircache/dirserv.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c
index c5286b0cb..50869c2b9 100644
--- a/src/feature/dircache/dirserv.c
+++ b/src/feature/dircache/dirserv.c
@@ -2616,6 +2616,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
* if there are additional header lines, as introduced in Bandwidth List spec
* version 1.1.0 */
   int line_is_after_headers = 0;
+  int rv = -1;
 
   /* Initialise line, so that we can't possibly run off the end. */
   memset(line, 0, sizeof(line));
@@ -2623,21 +2624,19 @@ dirserv_read_measured_bandwidths(const char *from_file,
   if (fp == NULL) {
 log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
  from_file);
-return -1;
+goto err;
   }
 
   /* 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;
+goto err;
   }
 
   if (!strlen(line) || line[strlen(line)-1] != '\n') {
 log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
  escaped(line));
-fclose(fp);
-return -1;
+goto err;
   }
 
   line[strlen(line)-1] = '\0';
@@ -2645,16 +2644,14 @@ dirserv_read_measured_bandwidths(const char *from_file,
   if (!ok) {
 log_warn(LD_DIRSERV, "Non-integer time in bandwidth file: %s",
  escaped(line));
-fclose(fp);
-return -1;
+goto err;
   }
 
   now = time(NULL);
   if ((now - file_time) > MAX_MEASUREMENT_AGE) {
 log_warn(LD_DIRSERV, "Bandwidth measurement file stale. Age: %u",
  (unsigned)(time(NULL) - file_time));
-fclose(fp);
-return -1;
+goto err;
   }
 
   if (routerstatuses)
@@ -2679,11 +2676,15 @@ dirserv_read_measured_bandwidths(const char *from_file,
   /* Now would be a nice time to clean the cache, too */
   dirserv_expire_measured_bw_cache(now);
 
-  fclose(fp);
   log_info(LD_DIRSERV,
"Bandwidth measurement file successfully read. "
"Applied %d measurements.", applied_lines);
-  return 0;
+  rv = 0;
+
+ err:
+  if (fp)
+fclose(fp);
+  return rv;
 }
 
 /** As dirserv_get_routerdescs(), but instead of getting signed_descriptor_t



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


[tor-commits] [tor/master] Use tor_getline() in dirserv.c to remove its upper line limit.

2018-07-10 Thread nickm
commit 951d59d706f116cbfa3d3700d9b342a736a571b2
Author: Nick Mathewson 
Date:   Tue Jul 10 10:32:09 2018 -0400

Use tor_getline() in dirserv.c to remove its upper line limit.

Closes ticket 26223.
---
 changes/bug26223   |  3 +++
 src/feature/dircache/dirserv.c | 10 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/changes/bug26223 b/changes/bug26223
new file mode 100644
index 0..e17b0529e
--- /dev/null
+++ b/changes/bug26223
@@ -0,0 +1,3 @@
+  o Minor features (directory authority):
+- There is no longer an artificial upper limit on the length of bandwidth
+  lines. Closes ticket 26223.
diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c
index 50869c2b9..57de6ab8e 100644
--- a/src/feature/dircache/dirserv.c
+++ b/src/feature/dircache/dirserv.c
@@ -2606,7 +2606,6 @@ int
 dirserv_read_measured_bandwidths(const char *from_file,
  smartlist_t *routerstatuses)
 {
-  char line[512];
   FILE *fp = tor_fopen_cloexec(from_file, "r");
   int applied_lines = 0;
   time_t file_time, now;
@@ -2617,9 +2616,10 @@ dirserv_read_measured_bandwidths(const char *from_file,
* version 1.1.0 */
   int line_is_after_headers = 0;
   int rv = -1;
+  char *line = NULL;
+  size_t n = 0;
 
   /* 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",
@@ -2628,7 +2628,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
   }
 
   /* If fgets fails, line is either unmodified, or indeterminate. */
-  if (!fgets(line, sizeof(line), fp)) {
+  if (tor_getline(,,fp) <= 0) {
 log_warn(LD_DIRSERV, "Empty bandwidth file");
 goto err;
   }
@@ -2659,7 +2659,7 @@ dirserv_read_measured_bandwidths(const char *from_file,
 
   while (!feof(fp)) {
 measured_bw_line_t parsed_line;
-if (fgets(line, sizeof(line), fp) && strlen(line)) {
+if (tor_getline(, , fp) >= 0) {
   if (measured_bw_line_parse(_line, line,
  line_is_after_headers) != -1) {
 /* This condition will be true when the first complete valid bw line
@@ -2682,6 +2682,8 @@ dirserv_read_measured_bandwidths(const char *from_file,
   rv = 0;
 
  err:
+  if (line)
+raw_free(line);
   if (fp)
 fclose(fp);
   return rv;



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


[tor-commits] [torspec/master] Correct a point in proposal 288.

2018-07-10 Thread nickm
commit c590145e6d3212a1c8802360e5a1d3e777306eb6
Author: Nick Mathewson 
Date:   Tue Jul 10 19:58:34 2018 -0400

Correct a point in proposal 288.

Previously our design had called for considering a SHAKE output B
bits at a time, but bitwise slicing is a pain.  Instead, consider
the output 64 bits at a time, mask off the high bits, and discard
values that lie outside the prime field.  Since P is very close to
2^B, nearly all values should be okay.
---
 proposals/288-privcount-with-shamir.txt | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/proposals/288-privcount-with-shamir.txt 
b/proposals/288-privcount-with-shamir.txt
index 76a065d..62faa1d 100644
--- a/proposals/288-privcount-with-shamir.txt
+++ b/proposals/288-privcount-with-shamir.txt
@@ -118,13 +118,16 @@ Status: Accepted
 
   1. For every Tally Reporter with index i, the client constructs a
  random 32-byte random value SEED_i.  The client then generates
- a pseudorandom bitstream of C*B bits using the SHAKE-256
+ a pseudorandom bitstream of using the SHAKE-256
  XOF with SEED_i as its input, and divides this stream into
  C values, with the c'th value denoted by MASK(i, c).
 
- [Because P is very close to a power of 2, nearly all seeds will
- produce MASK values in range 0...(P-1).  If any does not, the
- client picks a new seed.]
+ [To divide the stream into values, consider the stream 8 bytes at a
+ time as unsigned integers in network (big-endian) order. For each
+ such integer, clear the top (64-B) bits.  If the result is less than
+ P, then include the integer as one of the MASK(i, .) values.
+ Otherwise, discard this 8-byte segment and proceed to the next
+ value.]
 
   2. The client encrypts SEED_i using the public key of Tally
  Reporter i, and remembers this encrypted value.  It discards

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


[tor-commits] [depictor/master] Manipulate the query object directly to avoid it removing the .z suffix (when we update stem)

2018-07-10 Thread tom
commit 862a966e8f346c8a25016a141b81339cecd84ae3
Author: Tom Ritter 
Date:   Tue Jul 10 14:57:42 2018 -0500

Manipulate the query object directly to avoid it removing the .z suffix 
(when we update stem)

Closes #25782
---
 utility.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/utility.py b/utility.py
index d4f9a68..6b2ee54 100755
--- a/utility.py
+++ b/utility.py
@@ -57,7 +57,10 @@ def _get_documents(label, resource):
resource,
endpoints = [(authority.address, authority.dir_port)],
default_params = False,
+   start = False
)
+   # Re-add the .z suffix per #25782
+   query.resource = query.resource + ".z"
 
try:
start_time = time.time()

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


[tor-commits] [tor/master] Rename util_malloc to malloc.

2018-07-10 Thread nickm
commit 41640b65735ec6214aa5080c2143b0982a59bb93
Author: Nick Mathewson 
Date:   Tue Jul 10 15:16:57 2018 -0400

Rename util_malloc to malloc.
---
 src/core/or/or.h   | 2 +-
 src/lib/compress/compress.c| 2 +-
 src/lib/compress/compress_lzma.c   | 2 +-
 src/lib/container/bitarray.h   | 2 +-
 src/lib/container/bloomfilt.c  | 2 +-
 src/lib/container/buffers.c| 2 +-
 src/lib/container/handles.h| 2 +-
 src/lib/container/map.c| 2 +-
 src/lib/container/smartlist.c  | 2 +-
 src/lib/crypt_ops/aes.h| 2 +-
 src/lib/crypt_ops/crypto_digest.h  | 2 +-
 src/lib/crypt_ops/crypto_rand.c| 2 +-
 src/lib/ctime/di_ops.c | 2 +-
 src/lib/encoding/binascii.c| 2 +-
 src/lib/encoding/confline.c| 2 +-
 src/lib/encoding/cstring.c | 2 +-
 src/lib/encoding/time_fmt.c| 2 +-
 src/lib/evloop/compat_libevent.h   | 2 +-
 src/lib/evloop/procmon.c   | 2 +-
 src/lib/evloop/timers.c| 2 +-
 src/lib/fs/conffile.c  | 2 +-
 src/lib/fs/dir.c   | 2 +-
 src/lib/fs/files.c | 2 +-
 src/lib/fs/lockfile.c  | 2 +-
 src/lib/fs/mmap.c  | 2 +-
 src/lib/fs/path.c  | 2 +-
 src/lib/fs/storagedir.c| 2 +-
 src/lib/fs/userdb.c| 2 +-
 src/lib/lock/compat_mutex.c| 2 +-
 src/lib/lock/compat_mutex.h| 2 +-
 src/lib/log/escape.c   | 2 +-
 src/lib/log/ratelim.c  | 2 +-
 src/lib/log/torlog.c   | 2 +-
 src/lib/log/util_bug.c | 2 +-
 src/lib/log/win32err.c | 2 +-
 src/lib/malloc/include.am  | 4 ++--
 src/lib/malloc/{util_malloc.c => malloc.c} | 4 ++--
 src/lib/malloc/{util_malloc.h => malloc.h} | 2 +-
 src/lib/memarea/memarea.c  | 2 +-
 src/lib/meminfo/meminfo.c  | 2 +-
 src/lib/net/address.c  | 2 +-
 src/lib/net/resolve.c  | 2 +-
 src/lib/process/env.c  | 4 ++--
 src/lib/process/setuid.c   | 2 +-
 src/lib/process/subprocess.c   | 2 +-
 src/lib/process/waitpid.c  | 2 +-
 src/lib/sandbox/sandbox.c  | 2 +-
 src/lib/smartlist_core/smartlist_core.c| 2 +-
 src/lib/smartlist_core/smartlist_split.c   | 2 +-
 src/lib/string/printf.c| 2 +-
 src/lib/term/getpass.c | 2 +-
 src/test/test-memwipe.c| 2 +-
 src/test/test_crypto_openssl.c | 2 +-
 src/tools/tor-gencert.c| 2 +-
 src/tools/tor-resolve.c| 2 +-
 src/trunnel/trunnel-local.h| 2 +-
 56 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/core/or/or.h b/src/core/or/or.h
index 2e419eefd..9aca030c7 100644
--- a/src/core/or/or.h
+++ b/src/core/or/or.h
@@ -47,7 +47,7 @@
 #include "lib/log/escape.h"
 #include "lib/log/ratelim.h"
 #include "lib/log/util_bug.h"
-#include "lib/malloc/util_malloc.h"
+#include "lib/malloc/malloc.h"
 #include "lib/net/address.h"
 #include "lib/net/inaddr.h"
 #include "lib/net/socket.h"
diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c
index e87e788f1..ff1aea47a 100644
--- a/src/lib/compress/compress.c
+++ b/src/lib/compress/compress.c
@@ -32,7 +32,7 @@
 #include "lib/compress/compress_zlib.h"
 #include "lib/compress/compress_zstd.h"
 #include "lib/intmath/cmp.h"
-#include "lib/malloc/util_malloc.h"
+#include "lib/malloc/malloc.h"
 #include "lib/thread/threads.h"
 
 /** Total number of bytes allocated for compression state overhead. */
diff --git a/src/lib/compress/compress_lzma.c b/src/lib/compress/compress_lzma.c
index 3b6f91b84..9091832ed 100644
--- a/src/lib/compress/compress_lzma.c
+++ b/src/lib/compress/compress_lzma.c
@@ -17,7 +17,7 @@
 #include "lib/compress/compress_lzma.h"
 #include "lib/log/torlog.h"
 #include "lib/log/util_bug.h"
-#include "lib/malloc/util_malloc.h"
+#include "lib/malloc/malloc.h"
 #include "lib/thread/threads.h"
 
 #ifdef HAVE_LZMA
diff --git a/src/lib/container/bitarray.h b/src/lib/container/bitarray.h
index 172d56cc0..ae82a4ab4 100644
--- a/src/lib/container/bitarray.h
+++ b/src/lib/container/bitarray.h
@@ -15,7 +15,7 @@
 #include "orconfig.h"
 #include 
 #include "lib/cc/torint.h"
-#include "lib/malloc/util_malloc.h"
+#include "lib/malloc/malloc.h"
 
 #if SIZEOF_INT == 4
 #define BITARRAY_SHIFT 5
diff --git a/src/lib/container/bloomfilt.c b/src/lib/container/bloomfilt.c
index 1cab817e1..ea2d2917c 100644
--- a/src/lib/container/bloomfilt.c
+++ b/src/lib/container/bloomfilt.c
@@ -10,7 +10,7 @@
 
 #include 
 
-#include "lib/malloc/util_malloc.h"

[tor-commits] [tor/master] Rename torlog.[ch] to log.[ch]

2018-07-10 Thread nickm
commit e7f5f48d68553206b95cbb4f610702c887500124
Author: Nick Mathewson 
Date:   Tue Jul 10 15:20:28 2018 -0400

Rename torlog.[ch] to log.[ch]

Fun fact: these files used to be called log.[ch] until we ran into
conflicts with systems having a log.h file.  But now that we always
include "lib/log/log.h", we should be fine.
---
 src/core/crypto/onion_ntor.c  | 2 +-
 src/feature/dirauth/keypin.c  | 2 +-
 src/feature/nodelist/parsecommon.c| 2 +-
 src/feature/nodelist/torcert.c| 2 +-
 src/lib/compress/compress.c   | 2 +-
 src/lib/compress/compress_lzma.c  | 2 +-
 src/lib/compress/compress_none.c  | 2 +-
 src/lib/compress/compress_zlib.c  | 2 +-
 src/lib/compress/compress_zstd.c  | 2 +-
 src/lib/container/buffers.c   | 2 +-
 src/lib/crypt_ops/aes.c   | 2 +-
 src/lib/crypt_ops/crypto.c| 2 +-
 src/lib/crypt_ops/crypto_curve25519.c | 2 +-
 src/lib/crypt_ops/crypto_dh.c | 2 +-
 src/lib/crypt_ops/crypto_digest.c | 2 +-
 src/lib/crypt_ops/crypto_ed25519.c| 2 +-
 src/lib/crypt_ops/crypto_format.c | 2 +-
 src/lib/crypt_ops/crypto_rand.c   | 2 +-
 src/lib/crypt_ops/crypto_rsa.c| 2 +-
 src/lib/crypt_ops/crypto_rsa.h| 2 +-
 src/lib/crypt_ops/crypto_util.c   | 2 +-
 src/lib/encoding/binascii.c   | 2 +-
 src/lib/encoding/confline.c   | 2 +-
 src/lib/encoding/cstring.c| 2 +-
 src/lib/encoding/keyval.c | 2 +-
 src/lib/encoding/time_fmt.c   | 2 +-
 src/lib/evloop/compat_libevent.c  | 2 +-
 src/lib/evloop/procmon.c  | 2 +-
 src/lib/evloop/procmon.h  | 2 +-
 src/lib/evloop/timers.c   | 2 +-
 src/lib/evloop/workqueue.c| 2 +-
 src/lib/fs/conffile.c | 2 +-
 src/lib/fs/dir.c  | 2 +-
 src/lib/fs/files.c| 2 +-
 src/lib/fs/lockfile.c | 2 +-
 src/lib/fs/mmap.c | 2 +-
 src/lib/fs/path.c | 2 +-
 src/lib/fs/storagedir.c   | 2 +-
 src/lib/fs/userdb.c   | 2 +-
 src/lib/log/include.am| 4 ++--
 src/lib/log/{torlog.c => log.c}   | 4 ++--
 src/lib/log/{torlog.h => log.h}   | 2 +-
 src/lib/log/util_bug.c| 2 +-
 src/lib/log/util_bug.h| 2 +-
 src/lib/memarea/memarea.c | 2 +-
 src/lib/meminfo/meminfo.c | 2 +-
 src/lib/net/address.c | 2 +-
 src/lib/net/buffers_net.c | 2 +-
 src/lib/net/socket.c  | 2 +-
 src/lib/process/daemon.c  | 2 +-
 src/lib/process/env.c | 2 +-
 src/lib/process/pidfile.c | 2 +-
 src/lib/process/restrict.c| 2 +-
 src/lib/process/setuid.c  | 2 +-
 src/lib/process/subprocess.c  | 2 +-
 src/lib/process/waitpid.c | 2 +-
 src/lib/sandbox/sandbox.c | 2 +-
 src/lib/thread/compat_pthreads.c  | 2 +-
 src/lib/thread/compat_threads.c   | 2 +-
 src/lib/thread/compat_winthreads.c| 2 +-
 src/lib/thread/numcpus.c  | 2 +-
 src/lib/time/compat_time.c| 2 +-
 src/lib/time/tvdiff.c | 2 +-
 src/lib/tls/buffers_tls.c | 2 +-
 src/lib/tls/tortls.c  | 2 +-
 src/lib/trace/debug.h | 2 +-
 src/test/fuzz/fuzz_http.c | 2 +-
 src/test/fuzz/fuzz_http_connect.c | 2 +-
 src/test/log_test_helpers.c   | 2 +-
 src/test/test_bt_cl.c | 2 +-
 src/test/test_logging.c   | 2 +-
 src/test/test_status.c| 2 +-
 src/test/test_tortls.c| 2 +-
 src/test/test_util_slow.c | 2 +-
 src/tools/tor-gencert.c   | 2 +-
 src/tools/tor-resolve.c   | 2 +-
 76 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/src/core/crypto/onion_ntor.c b/src/core/crypto/onion_ntor.c
index 9e1e273ef..ea7261cb5 100644
--- a/src/core/crypto/onion_ntor.c
+++ b/src/core/crypto/onion_ntor.c
@@ -27,7 +27,7 @@
 #include "lib/crypt_ops/crypto_hkdf.h"
 #include "lib/crypt_ops/crypto_util.h"
 #include "lib/ctime/di_ops.h"
-#include "lib/log/torlog.h"
+#include "lib/log/log.h"
 #include "lib/log/util_bug.h"
 #include "core/crypto/onion_ntor.h"
 
diff --git a/src/feature/dirauth/keypin.c b/src/feature/dirauth/keypin.c
index 44e19985f..fd281377d 100644
--- a/src/feature/dirauth/keypin.c
+++ b/src/feature/dirauth/keypin.c
@@ -23,7 +23,7 @@
 #include "lib/fdio/fdio.h"
 #include "lib/fs/files.h"
 #include "lib/fs/mmap.h"
-#include "lib/log/torlog.h"
+#include "lib/log/log.h"
 #include "lib/log/util_bug.h"
 #include "lib/string/compat_ctype.h"
 #include "lib/string/printf.h"
diff --git a/src/feature/nodelist/parsecommon.c 
b/src/feature/nodelist/parsecommon.c
index 4f1c3fd42..3aaf8ac50 100644
--- a/src/feature/nodelist/parsecommon.c
+++ b/src/feature/nodelist/parsecommon.c
@@ -7,7 +7,7 @@
  **/
 
 

[tor-commits] [tor/master] Merge branch 'post-refactor-renaming'

2018-07-10 Thread nickm
commit c08b7b10c520db08e20e6ac5630f0a668d5ecf3a
Merge: 9ec80909e b6d0e7caa
Author: Nick Mathewson 
Date:   Tue Jul 10 15:35:49 2018 -0400

Merge branch 'post-refactor-renaming'

 src/core/crypto/onion_ntor.c | 2 +-
 src/core/or/or.h | 2 +-
 src/feature/dirauth/keypin.c | 2 +-
 src/feature/nodelist/parsecommon.c   | 2 +-
 src/feature/nodelist/torcert.c   | 2 +-
 src/lib/compress/compress.c  | 4 ++--
 src/lib/compress/compress_lzma.c | 4 ++--
 src/lib/compress/compress_none.c | 2 +-
 src/lib/compress/compress_zlib.c | 2 +-
 src/lib/compress/compress_zstd.c | 2 +-
 src/lib/container/bitarray.h | 2 +-
 src/lib/container/bloomfilt.c| 2 +-
 src/lib/container/buffers.c  | 4 ++--
 src/lib/container/handles.h  | 2 +-
 src/lib/container/map.c  | 2 +-
 src/lib/container/smartlist.c| 2 +-
 src/lib/crypt_ops/aes.c  | 2 +-
 src/lib/crypt_ops/aes.h  | 2 +-
 src/lib/crypt_ops/crypto.c   | 2 +-
 src/lib/crypt_ops/crypto_curve25519.c| 2 +-
 src/lib/crypt_ops/crypto_dh.c| 2 +-
 src/lib/crypt_ops/crypto_digest.c| 2 +-
 src/lib/crypt_ops/crypto_digest.h| 2 +-
 src/lib/crypt_ops/crypto_ed25519.c   | 2 +-
 src/lib/crypt_ops/crypto_format.c| 2 +-
 src/lib/crypt_ops/crypto_rand.c  | 4 ++--
 src/lib/crypt_ops/crypto_rsa.c   | 2 +-
 src/lib/crypt_ops/crypto_rsa.h   | 2 +-
 src/lib/crypt_ops/crypto_util.c  | 2 +-
 src/lib/ctime/di_ops.c   | 2 +-
 src/lib/encoding/binascii.c  | 4 ++--
 src/lib/encoding/confline.c  | 4 ++--
 src/lib/encoding/cstring.c   | 4 ++--
 src/lib/encoding/keyval.c| 2 +-
 src/lib/encoding/time_fmt.c  | 6 +++---
 src/lib/evloop/compat_libevent.c | 2 +-
 src/lib/evloop/compat_libevent.h | 2 +-
 src/lib/evloop/procmon.c | 4 ++--
 src/lib/evloop/procmon.h | 2 +-
 src/lib/evloop/timers.c  | 4 ++--
 src/lib/evloop/workqueue.c   | 2 +-
 src/lib/fs/conffile.c| 4 ++--
 src/lib/fs/dir.c | 4 ++--
 src/lib/fs/files.c   | 4 ++--
 src/lib/fs/lockfile.c| 4 ++--
 src/lib/fs/mmap.c| 4 ++--
 src/lib/fs/path.c| 4 ++--
 src/lib/fs/storagedir.c  | 4 ++--
 src/lib/fs/userdb.c  | 4 ++--
 src/lib/lock/compat_mutex.c  | 2 +-
 src/lib/lock/compat_mutex.h  | 2 +-
 src/lib/log/escape.c | 2 +-
 src/lib/log/include.am   | 4 ++--
 src/lib/log/{torlog.c => log.c}  | 8 
 src/lib/log/{torlog.h => log.h}  | 2 +-
 src/lib/log/ratelim.c| 2 +-
 src/lib/log/util_bug.c   | 4 ++--
 src/lib/log/util_bug.h   | 2 +-
 src/lib/log/win32err.c   | 2 +-
 src/lib/malloc/include.am| 4 ++--
 src/lib/malloc/{util_malloc.c => malloc.c}   | 4 ++--
 src/lib/malloc/{util_malloc.h => malloc.h}   | 2 +-
 src/lib/memarea/memarea.c| 4 ++--
 src/lib/meminfo/meminfo.c| 4 ++--
 src/lib/net/address.c| 4 ++--
 src/lib/net/buffers_net.c| 2 +-
 src/lib/net/resolve.c| 2 +-
 src/lib/net/socket.c | 2 +-
 src/lib/process/daemon.c | 2 +-
 src/lib/process/env.c| 6 +++---
 src/lib/process/pidfile.c| 2 +-
 src/lib/process/restrict.c   | 2 +-
 src/lib/process/setuid.c | 4 ++--
 src/lib/process/subprocess.c | 4 ++--
 src/lib/process/waitpid.c| 4 ++--
 src/lib/sandbox/sandbox.c| 4 ++--
 src/lib/smartlist_core/smartlist_core.c  | 2 +-
 src/lib/smartlist_core/smartlist_split.c | 2 +-
 src/lib/string/printf.c  | 2 +-
 src/lib/term/getpass.c   | 2 +-
 src/lib/thread/compat_pthreads.c | 2 +-
 src/lib/thread/compat_threads.c  | 2 +-
 src/lib/thread/compat_winthreads.c   | 2 +-
 src/lib/thread/numcpus.c | 2 +-
 src/lib/time/compat_time.c   | 2 +-
 src/lib/time/tvdiff.c| 2 +-
 src/lib/tls/buffers_tls.c| 2 +-
 src/lib/tls/tortls.c | 2 +-
 src/lib/trace/debug.h| 2 +-
 src/lib/wallclock/include.am 

[tor-commits] [tor/master] Rename tm_cvt to time_to_tm

2018-07-10 Thread nickm
commit b6d0e7caa4d11a0142a82aee065e8672b489ca51
Author: Nick Mathewson 
Date:   Tue Jul 10 15:25:53 2018 -0400

Rename tm_cvt to time_to_tm
---
 src/lib/encoding/time_fmt.c  | 2 +-
 src/lib/log/log.c| 2 +-
 src/lib/wallclock/include.am | 4 ++--
 src/lib/wallclock/{tm_cvt.c => time_to_tm.c} | 6 +++---
 src/lib/wallclock/{tm_cvt.h => time_to_tm.h} | 8 
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/lib/encoding/time_fmt.c b/src/lib/encoding/time_fmt.c
index 42b1cc646..a921fc681 100644
--- a/src/lib/encoding/time_fmt.c
+++ b/src/lib/encoding/time_fmt.c
@@ -21,7 +21,7 @@
 #include "lib/malloc/malloc.h"
 #include "lib/string/printf.h"
 #include "lib/string/scanf.h"
-#include "lib/wallclock/tm_cvt.h"
+#include "lib/wallclock/time_to_tm.h"
 
 #include 
 #include 
diff --git a/src/lib/log/log.c b/src/lib/log/log.c
index b89747d84..8349041ab 100644
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@ -45,7 +45,7 @@
 #include "lib/string/util_string.h"
 #include "lib/wallclock/tor_gettimeofday.h"
 #include "lib/wallclock/approx_time.h"
-#include "lib/wallclock/tm_cvt.h"
+#include "lib/wallclock/time_to_tm.h"
 #include "lib/fdio/fdio.h"
 
 #ifdef HAVE_ANDROID_LOG_H
diff --git a/src/lib/wallclock/include.am b/src/lib/wallclock/include.am
index 7864c21e1..1961639bd 100644
--- a/src/lib/wallclock/include.am
+++ b/src/lib/wallclock/include.am
@@ -7,7 +7,7 @@ endif
 
 src_lib_libtor_wallclock_a_SOURCES =   \
src/lib/wallclock/approx_time.c \
-   src/lib/wallclock/tm_cvt.c  \
+   src/lib/wallclock/time_to_tm.c  \
src/lib/wallclock/tor_gettimeofday.c
 
 src_lib_libtor_wallclock_testing_a_SOURCES = \
@@ -18,5 +18,5 @@ src_lib_libtor_wallclock_testing_a_CFLAGS = $(AM_CFLAGS) 
$(TEST_CFLAGS)
 noinst_HEADERS +=  \
src/lib/wallclock/approx_time.h \
src/lib/wallclock/timeval.h \
-   src/lib/wallclock/tm_cvt.h  \
+   src/lib/wallclock/time_to_tm.h  \
src/lib/wallclock/tor_gettimeofday.h
diff --git a/src/lib/wallclock/tm_cvt.c b/src/lib/wallclock/time_to_tm.c
similarity index 98%
rename from src/lib/wallclock/tm_cvt.c
rename to src/lib/wallclock/time_to_tm.c
index 4a51a4ab3..6543b97e3 100644
--- a/src/lib/wallclock/tm_cvt.c
+++ b/src/lib/wallclock/time_to_tm.c
@@ -4,14 +4,14 @@
 /* See LICENSE for licensing information */
 
 /**
- * \file tm_cvt.c
- * \brief Convert to and from struct tm, portably.
+ * \file time_to_tm.c
+ * \brief Convert to struct tm, portably.
  **/
 
 #include "orconfig.h"
 #include "lib/cc/torint.h"
 #include "lib/cc/compat_compiler.h"
-#include "lib/wallclock/tm_cvt.h"
+#include "lib/wallclock/time_to_tm.h"
 #include "lib/string/printf.h"
 #include "lib/err/torerr.h"
 
diff --git a/src/lib/wallclock/tm_cvt.h b/src/lib/wallclock/time_to_tm.h
similarity index 79%
rename from src/lib/wallclock/tm_cvt.h
rename to src/lib/wallclock/time_to_tm.h
index a1cdc80ef..0527a97b3 100644
--- a/src/lib/wallclock/tm_cvt.h
+++ b/src/lib/wallclock/time_to_tm.h
@@ -4,12 +4,12 @@
 /* See LICENSE for licensing information */
 
 /**
- * \file tm_cvt.h
- * \brief Header for tm_cvt.c
+ * \file time_to_tm.h
+ * \brief Header for time_to_tm.c
  **/
 
-#ifndef TOR_WALLCLOCK_TM_CVT_H
-#define TOR_WALLCLOCK_TM_CVT_H
+#ifndef TOR_WALLCLOCK_TIME_TO_TM_H
+#define TOR_WALLCLOCK_TIME_TO_TM_H
 
 #include 
 



___
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 changes file for 26481 (the big code movement)

2018-07-10 Thread nickm
commit 9ec80909ec7be3d9eea863dfc3f320bfe9072ae8
Author: Nick Mathewson 
Date:   Tue Jul 10 15:07:04 2018 -0400

Add a changes file for 26481 (the big code movement)
---
 changes/ticket26481 | 12 
 1 file changed, 12 insertions(+)

diff --git a/changes/ticket26481 b/changes/ticket26481
new file mode 100644
index 0..84d219ed8
--- /dev/null
+++ b/changes/ticket26481
@@ -0,0 +1,12 @@
+  o Major features (new code layout):
+   - Nearly all of Tor's source code has been moved around into more logical
+ places.  The "common" directory is now divided into a set of libraries
+ in "lib", and files in the "or" directory have been split into "core"
+ (logic absolutely needed for onion routing), "feature" (independent
+ modules in Tor), and "app" (to configure and invoke the rest of Tor).
+ See doc/HACKING/CodeStructure.md for more information. Closes ticket
+ 26481.
+
+ This refactoring is not complete: although the libraries have been
+ refactored to be acyclic, the main body of Tor is still too
+ interconnected.  We will attempt to improve this in the future.

___
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 'neel/fbsd-cfix'

2018-07-10 Thread nickm
commit 6711a172c0b8cca96843c14d0721fd8b48034956
Merge: 422abd4fa 6d58c20d9
Author: Nick Mathewson 
Date:   Tue Jul 10 14:50:49 2018 -0400

Merge remote-tracking branch 'neel/fbsd-cfix'

 changes/bug26715  |  5 +
 src/core/or/connection_edge.c |  7 +++
 src/lib/net/inaddr_st.h   | 12 
 3 files changed, 24 insertions(+)

diff --cc src/lib/net/inaddr_st.h
index cc72621e9,fd3fc12ba..dc4c6e3a0
--- a/src/lib/net/inaddr_st.h
+++ b/src/lib/net/inaddr_st.h
@@@ -3,20 -3,23 +3,32 @@@
   * Copyright (c) 2007-2018, The Tor Project, Inc. */
  /* See LICENSE for licensing information */
  
 -#ifndef TOR_IPV6_H
 -#define TOR_IPV6_H
 +/**
 + * \file inaddr_st.h
 + *
 + * \brief Define in6_addr, its members, and related types on platforms that
 + *lack it.
 + **/
 +
 +#ifndef TOR_INADDR_ST_H
 +#define TOR_INADDR_ST_H
  
+ #include "orconfig.h"
+ #include 
++
+ #ifdef HAVE_ARPA_INET_H
+ #include 
+ #endif
+ #ifdef HAVE_NETINET_IN_H
+ #include 
+ #endif
  #ifdef HAVE_NETINET_IN6_H
  #include 
  #endif
+ #ifdef HAVE_SYS_SOCKET_H
+ #include 
+ #endif
 +
  #ifdef _WIN32
  #include 
  #include 



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


[tor-commits] [tor/master] Fix build on FreeBSD post-refactor

2018-07-10 Thread nickm
commit 6d58c20d944b7b9056fc260f29452d2627b3e9f5
Author: Neel Chauhan 
Date:   Tue Jul 10 12:15:49 2018 -0400

Fix build on FreeBSD post-refactor
---
 changes/bug26715  | 5 +
 src/core/or/connection_edge.c | 7 +++
 src/lib/net/ipv6.h| 9 +
 3 files changed, 21 insertions(+)

diff --git a/changes/bug26715 b/changes/bug26715
new file mode 100644
index 0..85fc9d1ed
--- /dev/null
+++ b/changes/bug26715
@@ -0,0 +1,5 @@
+  o Major bugfixes (compilation):
+- Include additional headers in connection_edge.c and ipv6.h in order
+  to build correctly on FreeBSD post-refactor. Fixes bug 26715; bugfix
+  on 0.3.5.1-alpha. Patch by Neel Chauhan.
+
diff --git a/src/core/or/connection_edge.c b/src/core/or/connection_edge.c
index 8e8a5e21c..c51e42800 100644
--- a/src/core/or/connection_edge.c
+++ b/src/core/or/connection_edge.c
@@ -129,6 +129,13 @@
 #endif
 #endif /* defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H) */
 
+#ifdef HAVE_FCNTL_H
+#include 
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include 
+#endif
+
 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
 #include 
 #include 
diff --git a/src/lib/net/ipv6.h b/src/lib/net/ipv6.h
index 0a12e046a..fd3fc12ba 100644
--- a/src/lib/net/ipv6.h
+++ b/src/lib/net/ipv6.h
@@ -8,9 +8,18 @@
 
 #include "orconfig.h"
 #include 
+#ifdef HAVE_ARPA_INET_H
+#include 
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include 
+#endif
 #ifdef HAVE_NETINET_IN6_H
 #include 
 #endif
+#ifdef HAVE_SYS_SOCKET_H
+#include 
+#endif
 #ifdef _WIN32
 #include 
 #include 



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


[tor-commits] [tor/master] Remove changes file for 26715.

2018-07-10 Thread nickm
commit 3df548212a13c6f8a198ec869ee731e0f222f5bb
Author: Nick Mathewson 
Date:   Tue Jul 10 14:51:10 2018 -0400

Remove changes file for 26715.

(Bugfixes on bugs that have never been in a released version don't
need a changes file.)
---
 changes/bug26715 | 5 -
 1 file changed, 5 deletions(-)

diff --git a/changes/bug26715 b/changes/bug26715
deleted file mode 100644
index 85fc9d1ed..0
--- a/changes/bug26715
+++ /dev/null
@@ -1,5 +0,0 @@
-  o Major bugfixes (compilation):
-- Include additional headers in connection_edge.c and ipv6.h in order
-  to build correctly on FreeBSD post-refactor. Fixes bug 26715; bugfix
-  on 0.3.5.1-alpha. Patch by Neel Chauhan.
-

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


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

2018-07-10 Thread translation
commit 759b84e4ea38537ca48256ea6ed754c206a3ddbe
Author: Translation commit bot 
Date:   Tue Jul 10 18:49:18 2018 +

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

diff --git a/ka.json b/ka.json
index ea7437ca1..457dd7920 100644
--- a/ka.json
+++ b/ka.json
@@ -3,6 +3,6 @@
"id": "#https-1",
"control": "https-1",
"title": "Tor-ის გამოყენებისას, 
მაინც აქვთ მიმყურადებლებს 
შესაძლებლობა მოიპოვონ ჩემ 
მიერ ვებსაიტებისთვის გაზიარ
ებული მონაცემები, როგორიცაა 
ანგარიშის სახელები, პაროლები 
ველებში შეყვანილი სხვა ინფორ
მაცია?",
-   "description": "Tor protects eavesdroppers from 
learning sites that you visit. However, information sent unencrypted over the 
internet using plain HTTP can still be intercepted by exit relay operators or 
anyone observing the traffic between your exit relay and your destination 
website. If the site you are visiting uses HTTPS, then the traffic leaving your 
exit relay will be encrypted, and won't be visible to eavesdroppers.If you are using HTTPS, your 
website URL will begin with \"​https://\;.This visualization shows what information is visible to 
eavesdroppers with and without Tor Br
 owser and HTTPS encryption."
+   "description": "Tor გიცავთ 
მიმყურადებლებლებისგან, რომ 
მათ ვერ გაიგონ რომელ საიტებს 
ეწვიეთ. თუმცა, იმ შემთხვევაში, 
თუ დაუშიფრავ საიტს ეწვევით HTTP 
კავშირით, ბოლო გადამცემ წერ
ტილსა და საიტს შორის გაცვლილი 
ინფორმაცია, ნებისმიერი 
თვალყურისმდევნელისთვის 
იქნება ხელმისაწვდომი. თუ 
საიტი რომელსაც ნახულობთ 
იყენებს HTTPS კავშირს, მაშინ ბოლო 
გადამცემ წერტილსა და საიტს 
შორის მიმოცვლა დაშიფრáƒ
 £áƒšáƒ˜ იქნება და მიმყურ
ადებლებისთვის არ იქნება 
გადაცემული მონაცემები 
ხილული.რ
ოდესაც იყენებთ HTTPS კავშირს, 
თქვენი ვებსაიტის URL ბმულის 
თავსართი იქნება 
„https://“.გამოსახულებაზე 
ნაჩვენებია, თუ რომელი 
მონაცემებია მიმყურ
ადებლებისთვის ხილულáƒ
 ˜ და რომელი არა, Tor ბრაუზერისა 
და HTTPS კავშირის გამოყენებისას 
და მათ გარეშე."
 }
 }

___
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 'ticket26526_26532'

2018-07-10 Thread nickm
commit 422abd4fa3c2c9c10f4e7f83eced7416785e89c4
Merge: ef106ce78 a2c44a7a7
Author: Nick Mathewson 
Date:   Tue Jul 10 14:48:12 2018 -0400

Merge branch 'ticket26526_26532'

 changes/ticket26526 |   4 +
 changes/ticket26526_extra   |   3 +
 src/app/config/config.c |  14 +--
 src/app/config/statefile.c  |   1 +
 src/core/mainloop/main.c|   1 +
 src/core/or/or.h|   4 +-
 src/feature/nodelist/routerlist.c   |   1 +
 src/feature/rend/rendservice.c  |   1 +
 src/lib/net/address.c   | 223 ++--
 src/lib/net/address.h   |   9 +-
 src/lib/net/{ipv6.c => inaddr.c}|  57 +++--
 src/lib/net/{ipv4.h => inaddr.h}|  14 ++-
 src/lib/net/{ipv6.h => inaddr_st.h} |  21 ++--
 src/lib/net/include.am  |   7 +-
 src/lib/net/ipv4.c  |  57 -
 src/lib/net/resolve.c   | 183 +
 src/lib/net/resolve.h   |   8 +-
 src/test/test_addr.c|  62 +-
 src/test/test_config.c  |   1 +
 src/test/test_connection.c  |   2 +-
 src/test/test_controller.c  |   1 +
 src/test/test_helpers.c |   1 +
 src/test/test_options.c |   1 +
 src/test/test_pt.c  |   1 +
 src/tools/tor-gencert.c |  20 ++--
 src/tools/tor-resolve.c |  23 ++--
 26 files changed, 320 insertions(+), 400 deletions(-)

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


[tor-commits] [tor/master] Remove all users of addr_port_lookup outside of address.c

2018-07-10 Thread nickm
commit 2f657a1416f2f81dd1be900269c4ae9bdb29f52d
Author: Nick Mathewson 
Date:   Tue Jul 10 13:18:55 2018 -0400

Remove all users of addr_port_lookup outside of address.c

This function has a nasty API, since whether or not it invokes the
resolver depends on whether one of its arguments is NULL.  That's a
good way for accidents to happen.

This patch incidentally makes tor-resolve support socks hosts on
IPv6.
---
 changes/ticket26526_extra |  3 +++
 src/app/config/config.c   | 13 ++
 src/lib/net/address.h |  2 --
 src/test/test_addr.c  | 61 ++-
 src/tools/tor-gencert.c   | 18 --
 src/tools/tor-resolve.c   | 23 +-
 6 files changed, 30 insertions(+), 90 deletions(-)

diff --git a/changes/ticket26526_extra b/changes/ticket26526_extra
new file mode 100644
index 0..5495962ff
--- /dev/null
+++ b/changes/ticket26526_extra
@@ -0,0 +1,3 @@
+  o Minor features (tor-resolve):
+- The tor-resolve utility can now be used with IPv6 SOCKS proxies.
+  Side-effect of the refactoring for ticket 26526.
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 665732ea5..fa99fb0c8 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -6459,26 +6459,17 @@ parse_dir_authority_line(const char *line, 
dirinfo_type_t required_type,
   addrport = smartlist_get(items, 0);
   smartlist_del_keeporder(items, 0);
 
-  const char *addrport_sep = strchr(addrport, ':');
-  if (!addrport_sep) {
-log_warn(LD_CONFIG, "Error parsing DirAuthority address '%s' "
-"(':' not found)", addrport);
+  if (tor_addr_port_split(LOG_WARN, addrport, , _port) < 0) {
+log_warn(LD_CONFIG, "Error parsing DirAuthority address '%s'.", addrport);
 goto err;
   }
 
-  address = tor_strndup(addrport, addrport_sep - addrport);
   if (!string_is_valid_ipv4_address(address)) {
 log_warn(LD_CONFIG, "Error parsing DirAuthority address '%s' "
 "(invalid IPv4 address)", address);
 goto err;
   }
 
-  tor_free(address);
-
-  if (addr_port_lookup(LOG_WARN, addrport, , NULL, _port)<0) {
-log_warn(LD_CONFIG, "Error parsing DirAuthority address '%s'", addrport);
-goto err;
-  }
   if (!dir_port) {
 log_warn(LD_CONFIG, "Missing port in DirAuthority address '%s'",addrport);
 goto err;
diff --git a/src/lib/net/address.h b/src/lib/net/address.h
index f9e533f4a..e857b4068 100644
--- a/src/lib/net/address.h
+++ b/src/lib/net/address.h
@@ -325,8 +325,6 @@ int tor_addr_port_parse(int severity, const char *addrport,
 int tor_addr_hostname_is_local(const char *name);
 
 /* IPv4 helpers */
-int addr_port_lookup(int severity, const char *addrport, char **address,
-uint32_t *addr, uint16_t *port_out);
 int parse_port_range(const char *port, uint16_t *port_min_out,
  uint16_t *port_max_out);
 int addr_mask_get_bits(uint32_t mask);
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index 9ab921c5b..c85779e52 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -15,66 +15,10 @@
 #include 
 #endif
 
-/** Mocking replacement: only handles localhost. */
-static int
-mock_tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr_out)
-{
-  if (!strcmp(name, "localhost")) {
-if (family == AF_INET || family == AF_UNSPEC) {
-  tor_addr_from_ipv4h(addr_out, 0x7f01);
-  return 0;
-} else if (family == AF_INET6) {
-  char bytes[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 1 };
-  tor_addr_from_ipv6_bytes(addr_out, bytes);
-  return 0;
-}
-  }
-  return -1;
-}
-
 static void
 test_addr_basic(void *arg)
 {
-  uint32_t u32;
-  uint16_t u16;
-  char *cp;
-
-  /* Test addr_port_lookup */
-  (void)arg;
-  cp = NULL; u32 = 3; u16 = 3;
-  tt_assert(!addr_port_lookup(LOG_WARN, "1.2.3.4", , , ));
-  tt_str_op(cp,OP_EQ, "1.2.3.4");
-  tt_int_op(u32,OP_EQ, 0x01020304u);
-  tt_int_op(u16,OP_EQ, 0);
-  tor_free(cp);
-  tt_assert(!addr_port_lookup(LOG_WARN, "4.3.2.1:99", , , ));
-  tt_str_op(cp,OP_EQ, "4.3.2.1");
-  tt_int_op(u32,OP_EQ, 0x04030201u);
-  tt_int_op(u16,OP_EQ, 99);
-  tor_free(cp);
-
-  MOCK(tor_addr_lookup, mock_tor_addr_lookup);
-
-  tt_assert(!addr_port_lookup(LOG_WARN, "nonexistent.address:4040",
-   , NULL, ));
-  tt_str_op(cp,OP_EQ, "nonexistent.address");
-  tt_int_op(u16,OP_EQ, 4040);
-  tor_free(cp);
-  tt_assert(!addr_port_lookup(LOG_WARN, "localhost:", , , ));
-  tt_str_op(cp,OP_EQ, "localhost");
-  tt_int_op(u16,OP_EQ, );
-  tt_int_op(u32,OP_EQ, 0x7f01u);
-  tor_free(cp);
-  u32 = 3;
-  tt_assert(!addr_port_lookup(LOG_WARN, "localhost", NULL, , ));
-  tt_ptr_op(cp,OP_EQ, NULL);
-  tt_int_op(u32,OP_EQ, 0x7f01u);
-  tt_int_op(u16,OP_EQ, 0);
-  tor_free(cp);
-
-  tt_assert(addr_port_lookup(LOG_WARN, "localhost:3", , , NULL));
-  tor_free(cp);
+  (void) arg;
 
   

[tor-commits] [tor/master] Refactor ipv[46].[ch]

2018-07-10 Thread nickm
commit 5d8336c182777c36ebff561b420d67fcafb9a9f7
Author: Nick Mathewson 
Date:   Tue Jul 10 12:50:38 2018 -0400

Refactor ipv[46].[ch]

These are now combined into an inaddr.[ch], since their purpose is
to implement functions for struct in_addr and struct in6_addr.

The definitions for in6_addr and its allies are now in a separate
header, inaddr_st.h.

Closes ticket 26532.
---
 src/core/or/or.h|  3 +-
 src/lib/net/address.c   |  2 +-
 src/lib/net/address.h   |  2 +-
 src/lib/net/{ipv6.c => inaddr.c}| 57 +++--
 src/lib/net/{ipv4.h => inaddr.h}| 14 ++---
 src/lib/net/{ipv6.h => inaddr_st.h} | 21 +++---
 src/lib/net/include.am  |  7 ++---
 src/lib/net/ipv4.c  | 57 -
 src/tools/tor-gencert.c |  2 +-
 9 files changed, 76 insertions(+), 89 deletions(-)

diff --git a/src/core/or/or.h b/src/core/or/or.h
index 6edfd21df..a9bef9404 100644
--- a/src/core/or/or.h
+++ b/src/core/or/or.h
@@ -49,8 +49,7 @@
 #include "lib/log/util_bug.h"
 #include "lib/malloc/util_malloc.h"
 #include "lib/net/address.h"
-#include "lib/net/ipv4.h"
-#include "lib/net/ipv6.h"
+#include "lib/net/inaddr.h"
 #include "lib/net/resolve.h"
 #include "lib/net/socket.h"
 #include "lib/string/compat_ctype.h"
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index f3eddca7b..fbdd9591d 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -43,7 +43,7 @@
 #include "lib/log/torlog.h"
 #include "lib/log/escape.h"
 #include "lib/malloc/util_malloc.h"
-#include "lib/net/ipv4.h"
+#include "lib/net/inaddr.h"
 #include "lib/string/compat_ctype.h"
 #include "lib/string/compat_string.h"
 #include "lib/string/parse_int.h"
diff --git a/src/lib/net/address.h b/src/lib/net/address.h
index f8ea573c3..05ec1 100644
--- a/src/lib/net/address.h
+++ b/src/lib/net/address.h
@@ -14,7 +14,7 @@
 #include "orconfig.h"
 #include "lib/cc/torint.h"
 #include "lib/log/util_bug.h"
-#include "lib/net/ipv6.h"
+#include "lib/net/inaddr_st.h"
 #include "lib/net/nettypes.h"
 
 #ifdef HAVE_NETINET_IN_H
diff --git a/src/lib/net/ipv6.c b/src/lib/net/inaddr.c
similarity index 82%
rename from src/lib/net/ipv6.c
rename to src/lib/net/inaddr.c
index 630d6f1db..dcd8fcdd6 100644
--- a/src/lib/net/ipv6.c
+++ b/src/lib/net/inaddr.c
@@ -4,20 +4,20 @@
 /* See LICENSE for licensing information */
 
 /**
- * \file ipv6.c
- * \brief Functions for encoding and decoding IPv6 addresses
- *
- * (Because these functions are generic, they can also handle IPv4 addresses).
+ * \file inaddr.c
+ * \brief Convert in_addr and in6_addr to and from strings.
  **/
 
-#include "lib/net/ipv6.h"
-#include "lib/net/ipv4.h"
-#include "lib/string/util_string.h"
-#include "lib/string/compat_string.h"
+#include "lib/net/inaddr.h"
+
+#include "lib/cc/torint.h"
+#include "lib/log/util_bug.h"
+#include "lib/net/inaddr_st.h"
 #include "lib/string/compat_ctype.h"
+#include "lib/string/compat_string.h"
 #include "lib/string/printf.h"
 #include "lib/string/scanf.h"
-#include "lib/log/util_bug.h"
+#include "lib/string/util_string.h"
 
 #ifdef HAVE_ARPA_INET_H
 #include 
@@ -26,6 +26,45 @@
 #include 
 #include 
 
+#ifdef _WIN32
+#include 
+#endif
+
+/** Set *addr to the IP address (in dotted-quad notation) stored in *str.
+ * Return 1 on success, 0 if *str is badly formatted.
+ * (Like inet_aton(str,addr), but works on Windows and Solaris.)
+ */
+int
+tor_inet_aton(const char *str, struct in_addr* addr)
+{
+  unsigned a,b,c,d;
+  char more;
+  if (tor_sscanf(str, "%3u.%3u.%3u.%3u%c", ) != 4)
+return 0;
+  if (a > 255) return 0;
+  if (b > 255) return 0;
+  if (c > 255) return 0;
+  if (d > 255) return 0;
+  addr->s_addr = htonl((a<<24) | (b<<16) | (c<<8) | d);
+  return 1;
+}
+
+/** Given an IPv4 in_addr struct *in (in network order, as usual),
+ *  write it as a string into the buf_len-byte buffer in
+ *  buf. Returns a non-negative integer on success.
+ *  Returns -1 on failure.
+ */
+int
+tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len)
+{
+  uint32_t a = ntohl(in->s_addr);
+  return tor_snprintf(buf, buf_len, "%d.%d.%d.%d",
+  (int)(uint8_t)((a>>24)&0xff),
+  (int)(uint8_t)((a>>16)&0xff),
+  (int)(uint8_t)((a>>8 )&0xff),
+  (int)(uint8_t)((a)&0xff));
+}
+
 /** Given af==AF_INET and src a struct in_addr, or
  * af==AF_INET6 and src a struct in6_addr, try to format the
  * address and store it in the len-byte buffer dst.  Returns
diff --git a/src/lib/net/ipv4.h b/src/lib/net/inaddr.h
similarity index 66%
rename from src/lib/net/ipv4.h
rename to src/lib/net/inaddr.h
index 0127f09e0..121025a12 100644
--- a/src/lib/net/ipv4.h
+++ b/src/lib/net/inaddr.h
@@ -4,18 +4,24 @@
 /* See LICENSE for licensing information */
 
 /**
- * \file ipv4.h
- * \brief Header for ipv4.c
+ * \file inaddr.h
+ * \brief 

[tor-commits] [tor/master] Remove addr_port_lookup.

2018-07-10 Thread nickm
commit 8de48c111c09d76ecd00bb9dec67acb47890db01
Author: Nick Mathewson 
Date:   Tue Jul 10 13:30:44 2018 -0400

Remove addr_port_lookup.

This lets us cut the dependency from address.c to resolve.c: the
address.c module now has no paths to the libc resolver in it.
---
 changes/ticket26526   |  4 
 src/lib/net/address.c | 42 --
 2 files changed, 12 insertions(+), 34 deletions(-)

diff --git a/changes/ticket26526 b/changes/ticket26526
new file mode 100644
index 0..447b581df
--- /dev/null
+++ b/changes/ticket26526
@@ -0,0 +1,4 @@
+  o Code simplification and refactoring:
+- Utility functions that can perform a DNS lookup are now wholly
+  separated from those that can't, in separate headers and C
+  modules. Closes ticket 26526.
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 1d872043a..3b624da09 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -6,6 +6,9 @@
 /**
  * \file address.c
  * \brief Functions to use and manipulate the tor_addr_t structure.
+ *
+ * This module doesn't have any support for the libc resolver: that is all in
+ * resolve.c.
  **/
 
 #define ADDRESS_PRIVATE
@@ -37,7 +40,6 @@
 
 #include "lib/net/address.h"
 #include "lib/net/socket.h"
-#include "lib/net/resolve.h"
 #include "lib/container/smartlist.h"
 #include "lib/ctime/di_ops.h"
 #include "lib/log/torlog.h"
@@ -1748,7 +1750,7 @@ tor_addr_port_split(int severity, const char *addrport,
   tor_assert(addrport);
   tor_assert(address_out);
   tor_assert(port_out);
-  /* We need to check for IPv6 manually because addr_port_lookup() doesn't
+  /* We need to check for IPv6 manually because the logic below doesn't
* do a good job on IPv6 addresses that lack a port. */
   if (tor_addr_parse(_tmp, addrport) == AF_INET6) {
 *port_out = 0;
@@ -1756,30 +1758,11 @@ tor_addr_port_split(int severity, const char *addrport,
 return 0;
   }
 
-  return addr_port_lookup(severity, addrport, address_out, NULL, port_out);
-}
-
-/** Parse a string of the form "host[:port]" from addrport.  If
- * address is provided, set *address to a copy of the
- * host portion of the string.  If addr is provided, try to
- * resolve the host portion of the string and store it into
- * *addr (in host byte order).  If port_out is provided,
- * store the port number into *port_out, or 0 if no port is given.
- * If port_out is NULL, then there must be no port number in
- * addrport.
- * Return 0 on success, -1 on failure.
- */
-int
-addr_port_lookup(int severity, const char *addrport, char **address,
-uint32_t *addr, uint16_t *port_out)
-{
   const char *colon;
   char *address_ = NULL;
   int port_;
   int ok = 1;
 
-  tor_assert(addrport);
-
   colon = strrchr(addrport, ':');
   if (colon) {
 address_ = tor_strndup(addrport, colon-addrport);
@@ -1801,22 +1784,13 @@ addr_port_lookup(int severity, const char *addrport, 
char **address,
 port_ = 0;
   }
 
-  if (addr) {
-/* There's an addr pointer, so we need to resolve the hostname. */
-if (tor_lookup_hostname(address_,addr)) {
-  log_fn(severity, LD_NET, "Couldn't look up %s", escaped(address_));
-  ok = 0;
-  *addr = 0;
-}
-  }
-
-  if (address && ok) {
-*address = address_;
+  if (ok) {
+*address_out = address_;
   } else {
-if (address)
-  *address = NULL;
+*address_out = NULL;
 tor_free(address_);
   }
+
   if (port_out)
 *port_out = ok ? ((uint16_t) port_) : 0;
 



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


[tor-commits] [tor/master] Move tor_addr_{, port_}lookup to resolve.c

2018-07-10 Thread nickm
commit c2ddb7b231c640a292d261af265dd423cee09179
Author: Nick Mathewson 
Date:   Tue Jul 10 12:56:09 2018 -0400

Move tor_addr_{,port_}lookup to resolve.c
---
 src/lib/net/address.c | 179 
 src/lib/net/address.h |   5 --
 src/lib/net/resolve.c | 183 ++
 src/lib/net/resolve.h |   8 ++-
 4 files changed, 190 insertions(+), 185 deletions(-)

diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index fbdd9591d..1d872043a 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -234,127 +234,6 @@ tor_addr_make_null(tor_addr_t *a, sa_family_t family)
   a->family = family;
 }
 
-/** Similar behavior to Unix gethostbyname: resolve name, and set
- * *addr to the proper IP address and family. The family
- * argument (which must be AF_INET, AF_INET6, or AF_UNSPEC) declares a
- * preferred family, though another one may be returned if only one
- * family is implemented for this address.
- *
- * Return 0 on success, -1 on failure; 1 on transient failure.
- */
-MOCK_IMPL(int,
-tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
-{
-  /* Perhaps eventually this should be replaced by a tor_getaddrinfo or
-   * something.
-   */
-  struct in_addr iaddr;
-  struct in6_addr iaddr6;
-  tor_assert(name);
-  tor_assert(addr);
-  tor_assert(family == AF_INET || family == AF_INET6 || family == AF_UNSPEC);
-  if (!*name) {
-/* Empty address is an error. */
-return -1;
-  } else if (tor_inet_pton(AF_INET, name, )) {
-/* It's an IPv4 IP. */
-if (family == AF_INET6)
-  return -1;
-tor_addr_from_in(addr, );
-return 0;
-  } else if (tor_inet_pton(AF_INET6, name, )) {
-if (family == AF_INET)
-  return -1;
-tor_addr_from_in6(addr, );
-return 0;
-  } else {
-#ifdef HAVE_GETADDRINFO
-int err;
-struct addrinfo *res=NULL, *res_p;
-struct addrinfo *best=NULL;
-struct addrinfo hints;
-int result = -1;
-memset(, 0, sizeof(hints));
-hints.ai_family = family;
-hints.ai_socktype = SOCK_STREAM;
-err = tor_getaddrinfo(name, NULL, , );
-/* The check for 'res' here shouldn't be necessary, but it makes static
- * analysis tools happy. */
-if (!err && res) {
-  best = NULL;
-  for (res_p = res; res_p; res_p = res_p->ai_next) {
-if (family == AF_UNSPEC) {
-  if (res_p->ai_family == AF_INET) {
-best = res_p;
-break;
-  } else if (res_p->ai_family == AF_INET6 && !best) {
-best = res_p;
-  }
-} else if (family == res_p->ai_family) {
-  best = res_p;
-  break;
-}
-  }
-  if (!best)
-best = res;
-  if (best->ai_family == AF_INET) {
-tor_addr_from_in(addr,
- &((struct sockaddr_in*)best->ai_addr)->sin_addr);
-result = 0;
-  } else if (best->ai_family == AF_INET6) {
-tor_addr_from_in6(addr,
-  &((struct sockaddr_in6*)best->ai_addr)->sin6_addr);
-result = 0;
-  }
-  tor_freeaddrinfo(res);
-  return result;
-}
-return (err == EAI_AGAIN) ? 1 : -1;
-#else /* !(defined(HAVE_GETADDRINFO)) */
-struct hostent *ent;
-int err;
-#ifdef HAVE_GETHOSTBYNAME_R_6_ARG
-char buf[2048];
-struct hostent hostent;
-int r;
-r = gethostbyname_r(name, , buf, sizeof(buf), , );
-#elif defined(HAVE_GETHOSTBYNAME_R_5_ARG)
-char buf[2048];
-struct hostent hostent;
-ent = gethostbyname_r(name, , buf, sizeof(buf), );
-#elif defined(HAVE_GETHOSTBYNAME_R_3_ARG)
-struct hostent_data data;
-struct hostent hent;
-memset(, 0, sizeof(data));
-err = gethostbyname_r(name, , );
-ent = err ? NULL : 
-#else
-ent = gethostbyname(name);
-#ifdef _WIN32
-err = WSAGetLastError();
-#else
-err = h_errno;
-#endif
-#endif /* defined(HAVE_GETHOSTBYNAME_R_6_ARG) || ... */
-if (ent) {
-  if (ent->h_addrtype == AF_INET) {
-tor_addr_from_in(addr, (struct in_addr*) ent->h_addr);
-  } else if (ent->h_addrtype == AF_INET6) {
-tor_addr_from_in6(addr, (struct in6_addr*) ent->h_addr);
-  } else {
-tor_assert(0); // LCOV_EXCL_LINE: gethostbyname() returned bizarre type
-  }
-  return 0;
-}
-#ifdef _WIN32
-return (err == WSATRY_AGAIN) ? 1 : -1;
-#else
-return (err == TRY_AGAIN) ? 1 : -1;
-#endif
-#endif /* defined(HAVE_GETADDRINFO) */
-  }
-}
-
 /** Return true iff ip is an IP reserved to localhost or local networks
  * in RFC1918 or RFC4193 or RFC4291. (fec0::/10, deprecated by RFC3879, is
  * also treated as internal for now.)
@@ -1324,64 +1203,6 @@ tor_addr_parse(tor_addr_t *addr, const char *src)
   return result;
 }
 
-/** Parse an address or address-port combination from s, resolve the
- * address as needed, and put the result in addr_out and (optionally)
- * port_out.  Return 0 on success, negative on failure. */
-int

[tor-commits] [tor/master] Isolate resolve.h usage in the modules that really need it.

2018-07-10 Thread nickm
commit a2c44a7a7e3810bb18121561f012830da696724d
Author: Nick Mathewson 
Date:   Tue Jul 10 13:36:45 2018 -0400

Isolate resolve.h usage in the modules that really need it.

(Almost none of Tor should actually need to touch the platform resolver.)
---
 src/app/config/config.c   | 1 +
 src/app/config/statefile.c| 1 +
 src/core/mainloop/main.c  | 1 +
 src/core/or/or.h  | 1 -
 src/feature/nodelist/routerlist.c | 1 +
 src/feature/rend/rendservice.c| 1 +
 src/test/test_addr.c  | 1 +
 src/test/test_config.c| 1 +
 src/test/test_connection.c| 2 +-
 src/test/test_controller.c| 1 +
 src/test/test_helpers.c   | 1 +
 src/test/test_options.c   | 1 +
 src/test/test_pt.c| 1 +
 13 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/app/config/config.c b/src/app/config/config.c
index fa99fb0c8..1be1803f2 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -106,6 +106,7 @@
 #include "feature/client/transports.h"
 #include "feature/relay/ext_orport.h"
 #include "feature/dircommon/voting_schedule.h"
+#include "lib/net/resolve.h"
 #ifdef _WIN32
 #include 
 #endif
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index 8eeef4502..656dc2eec 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -43,6 +43,7 @@
 #include "lib/sandbox/sandbox.h"
 #include "app/config/statefile.h"
 #include "lib/encoding/confline.h"
+#include "lib/net/resolve.h"
 
 #include "app/config/or_state_st.h"
 
diff --git a/src/core/mainloop/main.c b/src/core/mainloop/main.c
index c5773ddfc..048397a2d 100644
--- a/src/core/mainloop/main.c
+++ b/src/core/mainloop/main.c
@@ -116,6 +116,7 @@
 #include "lib/sandbox/sandbox.h"
 #include "lib/fs/lockfile.h"
 #include "lib/net/buffers_net.h"
+#include "lib/net/resolve.h"
 #include "lib/tls/tortls.h"
 #include "lib/evloop/compat_libevent.h"
 #include "lib/encoding/confline.h"
diff --git a/src/core/or/or.h b/src/core/or/or.h
index a9bef9404..2e419eefd 100644
--- a/src/core/or/or.h
+++ b/src/core/or/or.h
@@ -50,7 +50,6 @@
 #include "lib/malloc/util_malloc.h"
 #include "lib/net/address.h"
 #include "lib/net/inaddr.h"
-#include "lib/net/resolve.h"
 #include "lib/net/socket.h"
 #include "lib/string/compat_ctype.h"
 #include "lib/string/compat_string.h"
diff --git a/src/feature/nodelist/routerlist.c 
b/src/feature/nodelist/routerlist.c
index 12226fee6..8b54329da 100644
--- a/src/feature/nodelist/routerlist.c
+++ b/src/feature/nodelist/routerlist.c
@@ -123,6 +123,7 @@
 #include "lib/sandbox/sandbox.h"
 #include "feature/nodelist/torcert.h"
 #include "lib/math/fp.h"
+#include "lib/net/resolve.h"
 
 #include "feature/dirauth/dirvote.h"
 #include "feature/dirauth/mode.h"
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index da4a98b3d..1a99bd56e 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -37,6 +37,7 @@
 #include "feature/nodelist/routerparse.h"
 #include "feature/nodelist/routerset.h"
 #include "lib/encoding/confline.h"
+#include "lib/net/resolve.h"
 
 #include "core/or/cpath_build_state_st.h"
 #include "core/or/crypt_path_st.h"
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index c85779e52..a9004048a 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -10,6 +10,7 @@
 #include "test/test.h"
 #include "feature/client/addressmap.h"
 #include "test/log_test_helpers.h"
+#include "lib/net/resolve.h"
 
 #ifdef HAVE_SYS_UN_H
 #include 
diff --git a/src/test/test_config.c b/src/test/test_config.c
index af3a8a7cf..393378b4c 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -10,6 +10,7 @@
 #define ROUTERSET_PRIVATE
 #include "core/or/or.h"
 #include "lib/net/address.h"
+#include "lib/net/resolve.h"
 #include "feature/client/addressmap.h"
 #include "feature/client/bridges.h"
 #include "core/or/circuitmux_ewma.h"
diff --git a/src/test/test_connection.c b/src/test/test_connection.c
index c423c6573..e716c83fe 100644
--- a/src/test/test_connection.c
+++ b/src/test/test_connection.c
@@ -20,6 +20,7 @@
 #include "feature/rend/rendcache.h"
 #include "feature/dircache/directory.h"
 #include "core/or/connection_or.h"
+#include "lib/net/resolve.h"
 
 #include "test/test_connection.h"
 #include "test/test_helpers.h"
@@ -899,4 +900,3 @@ struct testcase_t connection_tests[] = {
   { "failed_orconn_tracker", test_failed_orconn_tracker, TT_FORK, NULL, NULL },
   END_OF_TESTCASES
 };
-
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index 2ded04619..d0aa86844 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -14,6 +14,7 @@
 #include "feature/nodelist/nodelist.h"
 #include "test/test.h"
 #include "test/test_helpers.h"
+#include "lib/net/resolve.h"
 
 #include "feature/control/control_connection_st.h"
 #include "feature/dirclient/download_status_st.h"
diff --git a/src/test/test_helpers.c 

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

2018-07-10 Thread translation
commit 5495876bf340fac2b6046eb49a01372ee9de912c
Author: Translation commit bot 
Date:   Tue Jul 10 18:19:25 2018 +

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

diff --git a/ka.json b/ka.json
index 625e41dd5..ea7437ca1 100644
--- a/ka.json
+++ b/ka.json
@@ -2,7 +2,7 @@
 "https-1": {
"id": "#https-1",
"control": "https-1",
-   "title": "When I'm using Tor, can eavesdroppers still see the 
information I share with websites, like login information and things I type 
into forms?",
+   "title": "Tor-ის გამოყენებისას, 
მაინც აქვთ მიმყურადებლებს 
შესაძლებლობა მოიპოვონ ჩემ 
მიერ ვებსაიტებისთვის გაზიარ
ებული მონაცემები, როგორიცაა 
ანგარიშის სახელები, პაროლები 
ველებში შეყვანილი სხვა ინფორ
მაცია?",
"description": "Tor protects eavesdroppers from 
learning sites that you visit. However, information sent unencrypted over the 
internet using plain HTTP can still be intercepted by exit relay operators or 
anyone observing the traffic between your exit relay and your destination 
website. If the site you are visiting uses HTTPS, then the traffic leaving your 
exit relay will be encrypted, and won't be visible to eavesdroppers.If you are using HTTPS, your 
website URL will begin with \"​https://\;.This visualization shows what information is visible to 
eavesdroppers with and without Tor Br
 owser and HTTPS encryption."
 }
 }

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


[tor-commits] [translation/torbutton-abouttorproperties] Update translations for torbutton-abouttorproperties

2018-07-10 Thread translation
commit 5ab1ae80ec79b5e3fb69ca30ae7cb16ffddc1548
Author: Translation commit bot 
Date:   Tue Jul 10 18:18:05 2018 +

Update translations for torbutton-abouttorproperties
---
 ka/abouttor.properties | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/ka/abouttor.properties b/ka/abouttor.properties
index d0d3a64b8..2a4c20bdc 100644
--- a/ka/abouttor.properties
+++ b/ka/abouttor.properties
@@ -2,19 +2,19 @@
 # See LICENSE for licensing information.
 # vim: set sw=2 sts=2 ts=8 et:
 
-aboutTor.searchDDG.privacy=Search securely with DuckDuckGo.
+aboutTor.searchDDG.privacy=მოიძიეთ უსაფრ
თხოდ DuckDuckGo საძიებოს 
საშუალებით.
 # The following string is a link which replaces %1$S above.
 aboutTor.searchDDG.privacy.link=https://duckduckgo.com/privacy.html
 # The following string is a link which replaces %2$S above.
 aboutTor.searchDDG.search.link=https://duckduckgo.com/
 
-aboutTor.donationBanner.donate=Donate Now!
+aboutTor.donationBanner.donate=გაიღეთ შემოწირ
ულობა ახლავე!
 
-aboutTor.donationBanner.slogan=Tor: Powering Digital Resistance
+aboutTor.donationBanner.slogan=Tor: ციფრული მდგრ
ადობის გაძლიერება
 aboutTor.donationBanner.mozilla=Give today and Mozilla will match your gift!
 
-aboutTor.donationBanner.tagline1=Protecting Journalists, Whistleblowers, & 
Activists Since 2006
-aboutTor.donationBanner.tagline2=Networking Freedom Worldwide
-aboutTor.donationBanner.tagline3=Freedom Online
+aboutTor.donationBanner.tagline1=ჟურნალისტების, 
დარღვევების მამხილებლებისა 
და სამოქალაქო აქტივისტების 
დაცვა 2006 წლიდან
+aboutTor.donationBanner.tagline2=თავისუფლება 
ინტერნეტში მსოფლიო მასშტაბით
+aboutTor.donationBanner.tagline3=თავისუფალი ინტერ
ნეტი
 aboutTor.donationBanner.tagline4=Fostering Free Expression Worldwide
-aboutTor.donationBanner.tagline5=Protecting the Privacy of Millions Every Day
+aboutTor.donationBanner.tagline5=მილიონობით 
ადამიანის პირადი 
მონაცემების დაცვის უზრ
უნველყოფა ყოველდღიურად

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


[tor-commits] [translation/torbutton-aboutdialogdtd] Update translations for torbutton-aboutdialogdtd

2018-07-10 Thread translation
commit db693f6f2f54cf765ba8594b60b38e498f2893e0
Author: Translation commit bot 
Date:   Tue Jul 10 18:17:55 2018 +

Update translations for torbutton-aboutdialogdtd
---
 ka/aboutdialog.dtd | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/ka/aboutdialog.dtd b/ka/aboutdialog.dtd
index 5099ad74b..1d73386f6 100644
--- a/ka/aboutdialog.dtd
+++ b/ka/aboutdialog.dtd
@@ -1,19 +1,19 @@
-
+
 
-
-
+
+
 
-
+
 
-
-
+
+
 
-
+
 
 
-
+
 
-
+
 
-
-
+
+

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


[tor-commits] [translation/torbutton-aboutdialogdtd_completed] Update translations for torbutton-aboutdialogdtd_completed

2018-07-10 Thread translation
commit aa31254c472cb921fa3f054cd010d9211fc99969
Author: Translation commit bot 
Date:   Tue Jul 10 18:18:00 2018 +

Update translations for torbutton-aboutdialogdtd_completed
---
 ka/aboutdialog.dtd | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/ka/aboutdialog.dtd b/ka/aboutdialog.dtd
new file mode 100644
index 0..1d73386f6
--- /dev/null
+++ b/ka/aboutdialog.dtd
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

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


[tor-commits] [tor/master] Document the headers in src/app/config/

2018-07-10 Thread nickm
commit ef106ce7884b0af7adcf9f3965ebbe843a47912c
Author: Nick Mathewson 
Date:   Tue Jul 10 12:28:22 2018 -0400

Document the headers in src/app/config/
---
 src/app/config/confparse.h | 6 ++
 src/app/config/or_options_st.h | 6 ++
 src/app/config/or_state_st.h   | 6 ++
 src/app/config/statefile.h | 6 ++
 4 files changed, 24 insertions(+)

diff --git a/src/app/config/confparse.h b/src/app/config/confparse.h
index cbd2ea88e..570428c90 100644
--- a/src/app/config/confparse.h
+++ b/src/app/config/confparse.h
@@ -4,6 +4,12 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
+/**
+ * \file confparse.h
+ *
+ * \brief Header for confparse.c.
+ */
+
 #ifndef TOR_CONFPARSE_H
 #define TOR_CONFPARSE_H
 
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 0c0c5d32b..627b39aea 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -4,6 +4,12 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
+/**
+ * \file or_options_st.h
+ *
+ * \brief The or_options_t structure, which represents Tor's configuration.
+ */
+
 #ifndef TOR_OR_OPTIONS_ST_H
 #define TOR_OR_OPTIONS_ST_H
 
diff --git a/src/app/config/or_state_st.h b/src/app/config/or_state_st.h
index f1d5f981f..d95df6236 100644
--- a/src/app/config/or_state_st.h
+++ b/src/app/config/or_state_st.h
@@ -4,6 +4,12 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
+/**
+ * \file or_state_t
+ *
+ * \brief The or_state_t structure, which represents Tor's state file.
+ */
+
 #ifndef TOR_OR_STATE_ST_H
 #define TOR_OR_STATE_ST_H
 
diff --git a/src/app/config/statefile.h b/src/app/config/statefile.h
index e996d5b6e..6433affa6 100644
--- a/src/app/config/statefile.h
+++ b/src/app/config/statefile.h
@@ -4,6 +4,12 @@
  * Copyright (c) 2007-2018, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
+/**
+ * \file statefile.h
+ *
+ * \brief Header for statefile.c
+ */
+
 #ifndef TOR_STATEFILE_H
 #define TOR_STATEFILE_H
 

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


[tor-commits] [tor/master] File-level summary documentation for src/lib/*/*.[ch]

2018-07-10 Thread nickm
commit 4f42c923d61655235ebbae82f64106ecff9458d7
Author: Nick Mathewson 
Date:   Tue Jul 10 12:22:01 2018 -0400

File-level summary documentation for src/lib/*/*.[ch]
---
 src/lib/cc/compat_compiler.h   |  6 ++
 src/lib/cc/torint.h|  9 ++---
 src/lib/crypt_ops/crypto_curve25519.h  |  5 +
 src/lib/crypt_ops/crypto_ed25519.h |  5 +
 src/lib/crypt_ops/crypto_format.h  |  5 +
 src/lib/crypt_ops/crypto_openssl_mgt.c |  2 +-
 src/lib/crypt_ops/crypto_openssl_mgt.h |  4 ++--
 src/lib/defs/dh_sizes.h|  9 +
 src/lib/defs/x25519_sizes.h|  9 +
 src/lib/evloop/compat_libevent.h   |  5 +
 src/lib/evloop/timers.h|  6 +-
 src/lib/evloop/token_bucket.h  |  5 ++---
 src/lib/evloop/workqueue.h |  5 +
 src/lib/log/escape.c   |  5 +
 src/lib/log/escape.h   |  5 +
 src/lib/log/ratelim.c  |  5 +
 src/lib/log/ratelim.h  |  5 +
 src/lib/log/win32err.c |  5 +
 src/lib/log/win32err.h |  5 +
 src/lib/net/buffers_net.c  |  5 +
 src/lib/net/gethostname.c  |  5 +
 src/lib/net/gethostname.h  |  5 +
 src/lib/net/ipv4.c |  5 +
 src/lib/net/ipv4.h |  4 
 src/lib/net/ipv6.c |  7 +++
 src/lib/net/ipv6.h |  5 +
 src/lib/net/nettypes.h |  5 +
 src/lib/net/resolve.c  |  5 +
 src/lib/net/resolve.h  |  5 +
 src/lib/net/socket.c   |  6 ++
 src/lib/net/socket.h   |  5 +
 src/lib/net/socks5_status.h| 10 ++
 src/lib/osinfo/uname.c |  5 +
 src/lib/osinfo/uname.h |  9 +
 src/lib/process/daemon.c   |  5 +
 src/lib/process/daemon.h   |  5 +
 src/lib/process/env.c  |  5 +
 src/lib/process/env.h  |  5 +
 src/lib/process/pidfile.c  |  5 +
 src/lib/process/pidfile.h  |  5 +
 src/lib/process/restrict.c |  5 +
 src/lib/process/restrict.h |  4 ++--
 src/lib/process/setuid.c   |  5 +
 src/lib/process/setuid.h   |  5 +
 src/lib/process/subprocess.c   |  5 +
 src/lib/process/subprocess.h   |  5 +
 src/lib/process/waitpid.c  |  6 ++
 src/lib/smartlist_core/smartlist_core.h|  5 +
 src/lib/smartlist_core/smartlist_foreach.h |  5 +
 src/lib/smartlist_core/smartlist_split.c   |  5 +
 src/lib/smartlist_core/smartlist_split.h   |  5 +
 src/lib/string/compat_ctype.c  |  5 +
 src/lib/string/compat_ctype.h  |  5 +
 src/lib/string/compat_string.c |  6 ++
 src/lib/string/compat_string.h |  5 +
 src/lib/string/parse_int.c |  5 +
 src/lib/string/parse_int.h |  5 +
 src/lib/string/printf.c|  5 +
 src/lib/string/printf.h|  5 +
 src/lib/string/scanf.c |  5 +
 src/lib/string/scanf.h |  5 +
 src/lib/string/util_string.c   |  5 +
 src/lib/string/util_string.h   |  5 +
 src/lib/term/getpass.c |  5 +
 src/lib/term/getpass.h |  5 +
 src/lib/testsupport/testsupport.h  | 15 ++-
 src/lib/thread/numcpus.c   |  5 +
 src/lib/thread/numcpus.h   |  5 +
 src/lib/thread/threads.h   |  5 +
 src/lib/time/tvdiff.c  |  5 +
 src/lib/time/tvdiff.h  |  5 +
 src/lib/tls/buffers_tls.c  |  5 +
 src/lib/tls/buffers_tls.h  |  6 +-
 src/lib/trace/debug.h  |  5 +
 src/lib/trace/trace.c  |  8 +++-
 src/lib/trace/trace.h  |  6 +-
 src/lib/wallclock/approx_time.c|  5 +
 src/lib/wallclock/approx_time.h|  5 +
 src/lib/wallclock/timeval.c|  0
 src/lib/wallclock/timeval.h|  7 +++
 src/lib/wallclock/tm_cvt.c |  5 +
 src/lib/wallclock/tm_cvt.h |  5 +
 src/lib/wallclock/tor_gettimeofday.c   |  6 +++---
 src/lib/wallclock/tor_gettimeofday.h   |  5 +
 84 files changed, 428 insertions(+), 27 deletions(-)

diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index 0f1acc381..d45316b24 100644
--- 

[tor-commits] [tor/master] Add an initial CodeStructure.md file to doc/HACKING.

2018-07-10 Thread nickm
commit 23dc770f87c383a0e66055ae3ea2951c9a8a5c30
Author: Nick Mathewson 
Date:   Tue Jul 10 11:01:07 2018 -0400

Add an initial CodeStructure.md file to doc/HACKING.

Not complete or pretty, but better than nothing.
---
 doc/HACKING/CodeStructure.md | 129 +++
 doc/include.am   |   1 +
 2 files changed, 130 insertions(+)

diff --git a/doc/HACKING/CodeStructure.md b/doc/HACKING/CodeStructure.md
new file mode 100644
index 0..736d6cd48
--- /dev/null
+++ b/doc/HACKING/CodeStructure.md
@@ -0,0 +1,129 @@
+
+TODO: revise this to talk about how things are, rather than how things
+have changed.
+
+TODO: Make this into good markdown.
+
+
+
+For quite a while now, the program "tor" has been built from source
+code in just two directories: src/common and src/or.
+
+This has become more-or-less untenable, for a few reasons -- most
+notably of which is that it has led our code to become more
+spaghetti-ish than I can endorse with a clean conscience.
+
+So to fix that, we've gone and done a huge code movement in our git
+master branch, which will land in a release once Tor 0.3.5.1-alpha is
+out.
+
+Here's what we did:
+
+  * src/common has been turned into a set of static libraries.  These
+all live in the "src/lib/*" directories.  The dependencies between
+these libraries should have no cycles.  The libraries are:
+
+arch -- Headers to handle architectural differences
+cc -- headers to handle differences among compilers
+compress -- wraps zlib, zstd, lzma
+container -- high-level container types
+crypt_ops -- Cryptographic operations. Planning to split this into
+a higher and lower level library
+ctime -- Operations that need to run in constant-time. (Properly,
+data-invariant time)
+defs -- miscelaneous definitions needed throughout Tor.
+encoding -- transforming one data type into another, and various
+data types into strings.
+err -- lowest-level error handling, in cases where we can't use
+the logs because something that the logging system needs has broken.
+evloop -- Generic event-loop handling logic
+fdio -- Low-level IO wrapper functions for file descriptors.
+fs -- Operations on the filesystem
+intmath -- low-level integer math and misc bit-twiddling hacks
+lock -- low-level locking code
+log -- Tor's logging module.  This library sits roughly halfway up
+the library dependency diagram, since everything it depends on has to
+be carefully crafted to *not* log.
+malloc -- Low-level wrappers for the platform memory allocation functions.
+math -- Higher-level mathematical functions, and floating-point math
+memarea -- An arena allocator
+meminfo -- Functions for querying the current process's memory
+status and resources
+net -- Networking compatibility and convenience code
+osinfo -- Querying information about the operating system
+process -- Launching and querying the status of other processes
+sandbox -- Backend for the linux seccomp2 sandbox
+smartlist_core -- The lowest-level of the smartlist_t data type.
+Separated from the rest of the containers library because the logging
+subsystem depends on it.
+string -- Compatibility and convenience functions for manipulating
+C strings.
+term -- Terminal-related functions (currently limited to a getpass
+function).
+testsupport -- Macros for mocking, unit tests, etc.
+thread -- Higher-level thread compatibility code
+time -- Higher-level time management code, including format
+conversions and monotonic time
+tls -- Our wrapper around our TLS library
+trace -- Formerly src/trace -- a generic event tracing API
+wallclock -- Low-level time code, used by the log module.
+
+  * To ensure that the dependency graph in src/common remains under
+control, there is a tool that you can run called "make
+check-includes".  It verifies that each module in Tor only includes
+the headers that it is permitted to include, using a per-directory
+".may_include" file.
+
+  * The src/or/or.h header has been split into numerous smaller
+headers.  Notably, many important structures are now declared in a
+header called foo_st.h, where "foo" is the name of the structure.
+
+  * The src/or directory, which had most of Tor's code, had been split
+up into several directories.  This is still a work in progress:  This
+code has not itself been refactored, and its dependency graph is still
+a tangled web.  I hope we'll be working on that over the coming
+releases, but it will take a while to do.
+
+The new top-level source directories are:
+
+ src/core -- Code necessary to actually perform or use onion routing.
+ src/feature -- Code used only by some onion routing
+configurations, or only for a special purpose.
+ src/app -- Top-level code to run, invoke, and configure the
+lower-level code
+
+   The new second-level source directories are:
+ src/core/crypto -- High-level cryptographic 

[tor-commits] [tor/master] Describe "check-includes" in the CodingStandards.md file

2018-07-10 Thread nickm
commit 4793d913503f9349ca4b57d77a47bd1bbceecfe5
Author: Nick Mathewson 
Date:   Tue Jul 10 11:09:25 2018 -0400

Describe "check-includes" in the CodingStandards.md file
---
 doc/HACKING/CodingStandards.md | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/doc/HACKING/CodingStandards.md b/doc/HACKING/CodingStandards.md
index 6e6ef044d..4f229348e 100644
--- a/doc/HACKING/CodingStandards.md
+++ b/doc/HACKING/CodingStandards.md
@@ -214,6 +214,24 @@ We don't call `memcmp()` directly.  Use `fast_memeq()`, 
`fast_memneq()`,
 Also see a longer list of functions to avoid in:
 https://people.torproject.org/~nickm/tor-auto/internal/this-not-that.html
 
+What code can use what other code?
+--
+
+We're trying to simplify Tor's structure over time.  In the long run, we want
+Tor to be structured as a set of modules with *no circular dependencies*.
+
+This property is currently provided by the modules in src/lib, but not
+throughout the rest of Tor.  In general, higher-level libraries may use
+lower-level libraries, but never the reverse.
+
+To prevent new circular dependencies from landing, we have a tool that
+you can invoke with `make check-includes`, and which is run
+automatically as part of `make check`.  This tool will verify that, for
+every source directory with a `.may_include` file, no local headers are
+included except those specifically permitted by the `.may_include` file.
+When editing one of these files, please make sure that you are not
+introducing any cycles into Tor's dependency graph.
+
 Floating point math is hard
 ---
 

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


[tor-commits] [tor/master] Stop mentioning src/or and src/common in doc/HACKING

2018-07-10 Thread nickm
commit fa2d53aa6a5c33ea1ede4b3346d5abcc621e619f
Author: Nick Mathewson 
Date:   Tue Jul 10 11:03:45 2018 -0400

Stop mentioning src/or and src/common in doc/HACKING
---
 doc/HACKING/CodingStandards.md | 4 ++--
 doc/HACKING/Module.md  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/HACKING/CodingStandards.md b/doc/HACKING/CodingStandards.md
index b830ecea9..6e6ef044d 100644
--- a/doc/HACKING/CodingStandards.md
+++ b/doc/HACKING/CodingStandards.md
@@ -200,8 +200,8 @@ We have some wrapper functions like `tor_malloc`, 
`tor_free`, `tor_strdup`, and
 always succeed or exit.)
 
 You can get a full list of the compatibility functions that Tor provides by
-looking through `src/common/util*.h` and `src/common/compat*.h`.  You can see 
the
-available containers in `src/common/containers*.h`.  You should probably
+looking through `src/lib/*/*.h`.  You can see the
+available containers in `src/lib/containers/*.h`.  You should probably
 familiarize yourself with these modules before you write too much code, or
 else you'll wind up reinventing the wheel.
 
diff --git a/doc/HACKING/Module.md b/doc/HACKING/Module.md
index 6684e258d..9cf36090b 100644
--- a/doc/HACKING/Module.md
+++ b/doc/HACKING/Module.md
@@ -96,8 +96,8 @@ There are couples of "rules" you want to follow:
   filename as the one in the module. For example, this is a bad idea and
   should never be done:
 
-- `src/or/shared_random.c`
-- `src/or/dirauth/shared_random.c`
+- `src/feature/dirclient/shared_random.c`
+- `src/feature/dirauth/shared_random.c`
 
 * When you include headers from the module, **always** use the full module
   path in your statement. Example:



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


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

2018-07-10 Thread translation
commit 1ce2c22f886a0a2af0c853ed1cf13c03a4924da7
Author: Translation commit bot 
Date:   Tue Jul 10 12:49:44 2018 +

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

diff --git a/tr.json b/tr.json
index 8535f94df..110a801d9 100644
--- a/tr.json
+++ b/tr.json
@@ -27,7 +27,7 @@
"id": "#diger-5",
"control": "diger-5",
"title": "Bilgisayarımdaki dosyalar kilitlendi ve birileri dosyalarım 
için bir fidye ödemek üzere Tor Browser'ı indirmemi istiyor!",
-   "description": "We are so sorry, but you have been 
infected with malware. The Tor Project did not create this malware. The malware 
authors are asking you to download Tor Browser presumably to contact them 
anonymously with the ransom they're demanding from you. If this is your first 
introduction to Tor Browser, we understand that you might think we're bad 
people who enable even worse people. But please consider that our software is 
used every day for a wide variety of purposes by ​human rights activists, 
journalists, domestic violence survivors, whistleblowers, law enforcement 
officers, and many others. Unfortunately, the protection that our software can 
provide to these groups of people can also be abused by criminals and malware 
authors. The Tor Project does not support or condone the use of our software 
for malicious purposes."
+   "description": "Çok üzgünüz, ama size kötü 
amaçlı yazılım bulaşmış. Tor Project bu kötü amaçlı yazılımı 
yaratmadı. Kötü amaçlı yazılım yazarları, sizden talep ettikleri fidye 
için anonim olarak sizinle bağlantı kurmak üzere Tor Browser'ı indirmenizi 
isteyecektir. Bu, Tor Browser'a ilk girişinizse, kötünün kötüsü olan 
insanlar olduğumuzu düşünebileceğinizi anlıyoruz. Ancak, 
yazılımlarımızın her gün, insan hakları aktivistleri, gazeteciler, aile 
içi şiddet mağdurları, ihbarcılar, kolluk görevlileri ve daha 
birçokları tarafından çok çeşitli amaçlar için kullanıldığını 
düşünün. Ne yazık ki, yazılımımızın bu insan gruplarına 
sağlayabileceği koruma, suçlular ve kötü amaçlı yazılım yazarları 
tarafından da kötüye kullanılabilir. Tor Project, yazılımımızın 
zararlı amaçlarla kullanımını desteklemez veya bunlara göz yummaz."
  },
 "misc-6": {
"id": "#diger-6",

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


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

2018-07-10 Thread translation
commit 0dfb615fb65cdc0f3aa159e72cffd43bc0269899
Author: Translation commit bot 
Date:   Tue Jul 10 12:19:33 2018 +

Update translations for support-miscellaneous
---
 tr.json | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tr.json b/tr.json
index 52510822c..8535f94df 100644
--- a/tr.json
+++ b/tr.json
@@ -15,18 +15,18 @@
"id": "#diger-3",
"control": "diger-3",
"title": "Tor'a kim kaynak sağlıyor?",
-   "description": "Tor is funded by a number of 
different sponsors including US federal agencies, private foundations, and 
individual donors. Check out a list of all https://www.torproject.org/about/sponsors.html.en\;>our 
sponsors and a series of https://blog.torproject.org/category/tags/form-990\;>blog 
posts on our financial reports.We feel that 
talking openly about our funders and funding model is the best way to maintain 
trust with our community. We are always seeking more diversity in our funding 
sources, especially from foundations and individuals."
+   "description": "Tor, ABD federal kurumları, özel 
vakıflar ve bireysel bağışçılar da dahil olmak üzere bir dizi farklı 
sponsor tarafından finanse edilmektedir. Tüm listeye bir göz atın: https://www.torproject.org/about/sponsors.html.en\;>sponsorlarımız
 ve finansal raporlarımızdaki bir dizi https://blog.torproject.org/category/tags/form-990\;>blog 
gönderileriFonlarımız ve fonlama modelimiz 
hakkında açıkça konuşmanın topluluğumuza olan güveni korumanın en iyi 
yolu olduğunu düşünüyoruz. Fon kaynaklarımızda, özellikle vakıf ve 
bireylerden daha fazla çeşitlilik peşindeyiz."
  },
  "misc-4": {
"id": "#diger-4",
"control": "diger-4",
-   "title": "Can I use Tor with bittorrent?",
-   "description": "We do not recommend using Tor with 
bittorrent. For further details, please see our https://blog.torproject.org/bittorrent-over-tor-isnt-good-idea\;>​blog 
post on the subject."
+   "title": "Tor'u bittorrent ile kullanabilir miyim?",
+   "description": "Tor'u bittorrent ile kullanmanızı 
önermiyoruz. Daha fazla bilgi için lütfen bkz.https://blog.torproject.org/bittorrent-over-tor-isnt-good-idea\;>Konuyla 
ilgili blog yazısı."
  },
  "misc-5": {
"id": "#diger-5",
"control": "diger-5",
-   "title": "The files on my computer have been locked, and someone is 
demanding I download Tor Browser to pay a ransom for my files!",
+   "title": "Bilgisayarımdaki dosyalar kilitlendi ve birileri dosyalarım 
için bir fidye ödemek üzere Tor Browser'ı indirmemi istiyor!",
"description": "We are so sorry, but you have been 
infected with malware. The Tor Project did not create this malware. The malware 
authors are asking you to download Tor Browser presumably to contact them 
anonymously with the ransom they're demanding from you. If this is your first 
introduction to Tor Browser, we understand that you might think we're bad 
people who enable even worse people. But please consider that our software is 
used every day for a wide variety of purposes by ​human rights activists, 
journalists, domestic violence survivors, whistleblowers, law enforcement 
officers, and many others. Unfortunately, the protection that our software can 
provide to these groups of people can also be abused by criminals and malware 
authors. The Tor Project does not support or condone the use of our software 
for malicious purposes."
  },
 "misc-6": {

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