aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml12
-rw-r--r--changes/bug26535.0295
-rw-r--r--changes/bug26535.0325
-rw-r--r--changes/ticket265273
-rw-r--r--changes/ticket265603
-rw-r--r--configure.ac2
-rwxr-xr-xscripts/maint/checkIncludes.py16
-rw-r--r--src/common/.may_include3
-rw-r--r--src/lib/arch/bytes.h7
-rw-r--r--src/lib/cc/compat_compiler.h11
-rw-r--r--src/lib/cc/torint.h7
-rw-r--r--src/lib/compress/compress.c5
-rw-r--r--src/lib/compress/compress_buf.c6
-rw-r--r--src/lib/container/bitarray.h6
-rw-r--r--src/lib/container/bloomfilt.h6
-rw-r--r--src/lib/container/buffers.c4
-rw-r--r--src/lib/container/buffers.h3
-rw-r--r--src/lib/container/map.c5
-rw-r--r--src/lib/container/map.h6
-rw-r--r--src/lib/container/order.h6
-rw-r--r--src/lib/container/smartlist.c12
-rw-r--r--src/lib/container/smartlist.h6
-rw-r--r--src/lib/crypt_ops/.may_include1
-rw-r--r--src/lib/crypt_ops/crypto_pwbox.h7
-rw-r--r--src/lib/crypt_ops/crypto_s2k.h7
-rw-r--r--src/lib/defs/digest_sizes.h9
-rw-r--r--src/lib/encoding/binascii.h6
-rw-r--r--src/lib/encoding/confline.c11
-rw-r--r--src/lib/encoding/confline.h6
-rw-r--r--src/lib/encoding/cstring.c6
-rw-r--r--src/lib/encoding/cstring.h6
-rw-r--r--src/lib/encoding/keyval.c6
-rw-r--r--src/lib/encoding/keyval.h6
-rw-r--r--src/lib/encoding/time_fmt.c10
-rw-r--r--src/lib/encoding/time_fmt.h6
-rw-r--r--src/lib/err/backtrace.c4
-rw-r--r--src/lib/err/backtrace.h6
-rw-r--r--src/lib/err/torerr.c8
-rw-r--r--src/lib/fdio/fdio.c6
-rw-r--r--src/lib/fdio/fdio.h6
-rw-r--r--src/lib/fs/conffile.c6
-rw-r--r--src/lib/fs/conffile.h6
-rw-r--r--src/lib/fs/dir.c7
-rw-r--r--src/lib/fs/dir.h6
-rw-r--r--src/lib/fs/files.c6
-rw-r--r--src/lib/fs/files.h6
-rw-r--r--src/lib/fs/freespace.c6
-rw-r--r--src/lib/fs/lockfile.c7
-rw-r--r--src/lib/fs/lockfile.h6
-rw-r--r--src/lib/fs/mmap.c6
-rw-r--r--src/lib/fs/mmap.h10
-rw-r--r--src/lib/fs/path.c6
-rw-r--r--src/lib/fs/path.h6
-rw-r--r--src/lib/fs/storagedir.c11
-rw-r--r--src/lib/fs/storagedir.h6
-rw-r--r--src/lib/fs/userdb.c6
-rw-r--r--src/lib/fs/userdb.h6
-rw-r--r--src/lib/fs/winlib.c9
-rw-r--r--src/lib/fs/winlib.h6
-rw-r--r--src/lib/intmath/addsub.c8
-rw-r--r--src/lib/intmath/addsub.h6
-rw-r--r--src/lib/intmath/bits.c6
-rw-r--r--src/lib/intmath/bits.h6
-rw-r--r--src/lib/intmath/cmp.h6
-rw-r--r--src/lib/intmath/logic.h6
-rw-r--r--src/lib/intmath/muldiv.c6
-rw-r--r--src/lib/intmath/muldiv.h6
-rw-r--r--src/lib/intmath/weakrng.c9
-rw-r--r--src/lib/intmath/weakrng.h6
-rw-r--r--src/lib/lock/compat_mutex.c6
-rw-r--r--src/lib/lock/compat_mutex.h6
-rw-r--r--src/lib/lock/compat_mutex_pthreads.c6
-rw-r--r--src/lib/lock/compat_mutex_winthreads.c6
-rw-r--r--src/lib/malloc/util_malloc.h8
-rw-r--r--src/lib/math/fp.c6
-rw-r--r--src/lib/math/fp.h6
-rw-r--r--src/lib/math/laplace.c6
-rw-r--r--src/lib/math/laplace.h6
-rw-r--r--src/lib/memarea/memarea.c4
-rw-r--r--src/lib/memarea/memarea.h7
-rw-r--r--src/lib/meminfo/meminfo.c7
-rw-r--r--src/lib/meminfo/meminfo.h6
-rw-r--r--src/lib/net/alertsock.c11
-rw-r--r--src/lib/net/alertsock.h6
-rw-r--r--src/lib/net/buffers_net.h5
-rw-r--r--src/lib/process/.may_include1
-rw-r--r--src/lib/string/compat_string.h21
-rw-r--r--src/lib/string/printf.h4
-rw-r--r--src/lib/string/util_string.h24
-rw-r--r--src/lib/tls/.may_include8
-rw-r--r--src/test/hs_ntor_ref.py7
-rwxr-xr-xsrc/test/ntor_ref.py9
92 files changed, 556 insertions, 69 deletions
diff --git a/.travis.yml b/.travis.yml
index f37f9a23ff..cb00b0393c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,11 +42,12 @@ addons:
packages:
## Required dependencies
- libevent-dev
- - libseccomp2
- zlib1g-dev
## Optional dependencies
+ - libcap-dev
- liblzma-dev
- libscrypt-dev
+ - libseccomp-dev
## zstd doesn't exist in Ubuntu Trusty
#- libzstd
@@ -60,6 +61,7 @@ env:
global:
## The Travis CI environment allows us two cores, so let's use both.
- MAKEFLAGS="-j 2"
+ - HARDENING_OPTIONS="--enable-fragile-hardening"
matrix:
## Leave at least one entry here or Travis seems to generate a
## matrix entry with empty matrix environment variables. Leaving
@@ -109,6 +111,10 @@ matrix:
env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode"
- compiler: gcc
env: MODULES_OPTIONS="--disable-module-dirauth"
+ - compiler: gcc
+ env: HARDENING_OPTIONS="" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
+ - compiler: gcc
+ env: DISTCHECK="yes" HARDENING_OPTIONS="" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode"
## The "sudo: required" forces non-containerized builds, working
## around a Travis CI environment issue: clang LeakAnalyzer fails
## because it requires ptrace and the containerized environment no
@@ -154,10 +160,10 @@ install:
script:
- ./autogen.sh
- - ./configure $RUST_OPTIONS $COVERAGE_OPTIONS $MODULES_OPTIONS --disable-asciidoc --enable-fatal-warnings --disable-silent-rules --enable-fragile-hardening
+ - ./configure $RUST_OPTIONS $COVERAGE_OPTIONS $MODULES_OPTIONS --disable-asciidoc --enable-fatal-warnings --disable-silent-rules $HARDENING_OPTIONS
## We run `make check` because that's what https://jenkins.torproject.org does.
- if [[ "$DISTCHECK" == "" ]]; then make check; fi
- - if [[ "$DISTCHECK" != "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$RUST_OPTIONS $COVERAGE_OPTIONS --disable-asciidoc --enable-fatal-warnings --disable-silent-rules --enable-fragile-hardening"; fi
+ - if [[ "$DISTCHECK" != "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$RUST_OPTIONS $COVERAGE_OPTIONS --disable-asciidoc --enable-fatal-warnings --disable-silent-rules $HARDENING_OPTIONS"; fi
after_failure:
## `make check` will leave a log file with more details of test failures.
diff --git a/changes/bug26535.029 b/changes/bug26535.029
new file mode 100644
index 0000000000..111b539f17
--- /dev/null
+++ b/changes/bug26535.029
@@ -0,0 +1,5 @@
+ o Minor bugfixes (testing, compatibility):
+ - When running the ntor_ref.py test, make sure only to pass strings
+ (rather than "bytes" objects) to the Python subprocess module.
+ Python 3 on Windows seems to require this. Fixes bug 26535; bugfix on
+ 0.2.5.5-alpha.
diff --git a/changes/bug26535.032 b/changes/bug26535.032
new file mode 100644
index 0000000000..395d08d816
--- /dev/null
+++ b/changes/bug26535.032
@@ -0,0 +1,5 @@
+ o Minor bugfixes (testing, compatibility):
+ - When running the hs_ntor_ref.py test, make sure only to pass strings
+ (rather than "bytes" objects) to the Python subprocess module.
+ Python 3 on Windows seems to require this. Fixes bug 26535; bugfix on
+ 0.3.1.1-alpha.
diff --git a/changes/ticket26527 b/changes/ticket26527
new file mode 100644
index 0000000000..ea1d650fef
--- /dev/null
+++ b/changes/ticket26527
@@ -0,0 +1,3 @@
+ o Code simplification and refactoring:
+ - Remove ATTR_NONNULL macro from codebase. Resolves
+ ticket 26527.
diff --git a/changes/ticket26560 b/changes/ticket26560
new file mode 100644
index 0000000000..5b4fb1bfe7
--- /dev/null
+++ b/changes/ticket26560
@@ -0,0 +1,3 @@
+ o Minor features (continuous integration):
+ - Install libcap-dev and libseccomp2-dev so these optional
+ dependencies get tested on Travis CI. Closes ticket 26560.
diff --git a/configure.ac b/configure.ac
index 97e8dadeba..98635bcbd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -610,6 +610,8 @@ AC_CHECK_FUNCS(
sigaction \
socketpair \
statvfs \
+ strncasecmp \
+ strcasecmp \
strlcat \
strlcpy \
strnlen \
diff --git a/scripts/maint/checkIncludes.py b/scripts/maint/checkIncludes.py
index 3c611675e4..9da15a2b9c 100755
--- a/scripts/maint/checkIncludes.py
+++ b/scripts/maint/checkIncludes.py
@@ -20,8 +20,10 @@ INCLUDE_PATTERN = re.compile(r'\s*#\s*include\s+"([^"]*)"')
RULES_FNAME = ".may_include"
class Rules(object):
- def __init__(self):
+ def __init__(self, dirpath):
+ self.dirpath = dirpath
self.patterns = []
+ self.usedPatterns = set()
def addPattern(self, pattern):
self.patterns.append(pattern)
@@ -29,6 +31,7 @@ class Rules(object):
def includeOk(self, path):
for pattern in self.patterns:
if fnmatch.fnmatchcase(path, pattern):
+ self.usedPatterns.add(pattern)
return True
return False
@@ -48,8 +51,13 @@ class Rules(object):
#print(fname)
self.applyToLines(iter(f), " of {}".format(fname))
+ def noteUnusedRules(self):
+ for p in self.patterns:
+ if p not in self.usedPatterns:
+ print("Pattern {} in {} was never used.".format(p, self.dirpath))
+
def load_include_rules(fname):
- result = Rules()
+ result = Rules(os.path.split(fname)[0])
with open(fname, 'r') as f:
for line in f:
line = line.strip()
@@ -58,12 +66,16 @@ def load_include_rules(fname):
result.addPattern(line)
return result
+list_unused = False
+
for dirpath, dirnames, fnames in os.walk("src"):
if ".may_include" in fnames:
rules = load_include_rules(os.path.join(dirpath, RULES_FNAME))
for fname in fnames:
if fname_is_c(fname):
rules.applyToFile(os.path.join(dirpath,fname))
+ if list_unused:
+ rules.noteUnusedRules()
if trouble:
err(
diff --git a/src/common/.may_include b/src/common/.may_include
index fab9ad0da8..a01a9db0b9 100644
--- a/src/common/.may_include
+++ b/src/common/.may_include
@@ -3,9 +3,6 @@ common/*.h
lib/*/*.h
# XXXX These all belong somewhere else
-ht.h
-linux_syscalls.inc
siphash.h
src/ext/timeouts/timeout.c
tor_queue.h
-tor_readpassphrase.h
diff --git a/src/lib/arch/bytes.h b/src/lib/arch/bytes.h
index 4359b0f723..a2e2224d3c 100644
--- a/src/lib/arch/bytes.h
+++ b/src/lib/arch/bytes.h
@@ -6,6 +6,13 @@
#ifndef TOR_BYTES_H
#define TOR_BYTES_H
+/**
+ * \file bytes.h
+ *
+ * \brief Inline functions for reading and writing multibyte values from
+ * the middle of strings, and for manipulating byte order.
+ **/
+
#include <string.h>
#include "lib/cc/torint.h"
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h
index c631a7e821..084923eb09 100644
--- a/src/lib/cc/compat_compiler.h
+++ b/src/lib/cc/compat_compiler.h
@@ -125,16 +125,6 @@
#define ATTR_MALLOC __attribute__((malloc))
#define ATTR_NORETURN __attribute__((noreturn))
#define ATTR_WUR __attribute__((warn_unused_result))
-/* Alas, nonnull is not at present a good idea for us. We'd like to get
- * warnings when we pass NULL where we shouldn't (which nonnull does, albeit
- * spottily), but we don't want to tell the compiler to make optimizations
- * with the assumption that the argument can't be NULL (since this would make
- * many of our checks go away, and make our code less robust against
- * programming errors). Unfortunately, nonnull currently does both of these
- * things, and there's no good way to split them up.
- *
- * #define ATTR_NONNULL(x) __attribute__((nonnull x)) */
-#define ATTR_NONNULL(x)
#define ATTR_UNUSED __attribute__ ((unused))
/** Macro: Evaluates to <b>exp</b> and hints the compiler that the value
@@ -158,7 +148,6 @@
#define ATTR_CONST
#define ATTR_MALLOC
#define ATTR_NORETURN
-#define ATTR_NONNULL(x)
#define ATTR_UNUSED
#define ATTR_WUR
#define PREDICT_LIKELY(exp) (exp)
diff --git a/src/lib/cc/torint.h b/src/lib/cc/torint.h
index 55b15402f2..5d536e78b5 100644
--- a/src/lib/cc/torint.h
+++ b/src/lib/cc/torint.h
@@ -11,6 +11,12 @@
#ifndef TOR_TORINT_H
#define TOR_TORINT_H
+/**
+ * \file torint.h
+ *
+ * \brief Integer definitions used throughout Tor.
+ **/
+
#include "orconfig.h"
#ifdef HAVE_STDINT_H
@@ -376,4 +382,3 @@ typedef uint32_t uintptr_t;
#define SIZE_T_CEILING ((size_t)(SSIZE_MAX-16))
#endif /* !defined(TOR_TORINT_H) */
-
diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c
index 2cb5dbaec2..e87e788f14 100644
--- a/src/lib/compress/compress.c
+++ b/src/lib/compress/compress.c
@@ -5,7 +5,10 @@
/**
* \file compress.c
- * \brief Common compression API.
+ * \brief Common compression API implementation.
+ *
+ * This file provides a unified interface to all the compression libraries Tor
+ * knows how to use.
**/
#include "orconfig.h"
diff --git a/src/lib/compress/compress_buf.c b/src/lib/compress/compress_buf.c
index 4b88772382..63ee9e0102 100644
--- a/src/lib/compress/compress_buf.c
+++ b/src/lib/compress/compress_buf.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file compress_buf.c
+ *
+ * \brief Working with compressed data in buffers.
+ **/
+
#define BUFFERS_PRIVATE
#include "lib/cc/compat_compiler.h"
#include "lib/container/buffers.h"
diff --git a/src/lib/container/bitarray.h b/src/lib/container/bitarray.h
index 2cea433fb0..172d56cc06 100644
--- a/src/lib/container/bitarray.h
+++ b/src/lib/container/bitarray.h
@@ -6,6 +6,12 @@
#ifndef TOR_BITARRAY_H
#define TOR_BITARRAY_H
+/**
+ * \file bitarray.h
+ *
+ * \brief Implements a variable-sized (but non-resizeable) bit-array.
+ **/
+
#include "orconfig.h"
#include <string.h>
#include "lib/cc/torint.h"
diff --git a/src/lib/container/bloomfilt.h b/src/lib/container/bloomfilt.h
index 577acf5e48..14f909cb19 100644
--- a/src/lib/container/bloomfilt.h
+++ b/src/lib/container/bloomfilt.h
@@ -6,6 +6,12 @@
#ifndef TOR_BLOOMFILT_H
#define TOR_BLOOMFILT_H
+/**
+ * \file bloomfilt.h
+ *
+ * \brief Header for bloomfilt.c
+ **/
+
#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/container/bitarray.h"
diff --git a/src/lib/container/buffers.c b/src/lib/container/buffers.c
index 0e98033bfd..5849704e35 100644
--- a/src/lib/container/buffers.c
+++ b/src/lib/container/buffers.c
@@ -16,6 +16,10 @@
* buffers: one for incoming data, and one for outcoming data. These are fed
* and drained from functions in connection.c, trigged by events that are
* monitored in main.c.
+ *
+ * This module only handles the buffer implementation itself. To use a buffer
+ * with the network, a compressor, or a TLS connection, see the other buffer_*
+ * modules.
**/
#define BUFFERS_PRIVATE
diff --git a/src/lib/container/buffers.h b/src/lib/container/buffers.h
index 8b16fb298b..c48f83cfc7 100644
--- a/src/lib/container/buffers.h
+++ b/src/lib/container/buffers.h
@@ -6,6 +6,7 @@
/**
* \file buffers.h
+ *
* \brief Header file for buffers.c.
**/
@@ -20,8 +21,6 @@
typedef struct buf_t buf_t;
-struct tor_compress_state_t;
-
buf_t *buf_new(void);
buf_t *buf_new_with_capacity(size_t size);
size_t buf_get_default_chunk_size(const buf_t *buf);
diff --git a/src/lib/container/map.c b/src/lib/container/map.c
index 3d84356cc8..0602eac891 100644
--- a/src/lib/container/map.c
+++ b/src/lib/container/map.c
@@ -4,8 +4,9 @@
/* See LICENSE for licensing information */
/**
- * \file container.c
- * \brief Hash table implementations of a string-to-void* map, and of
+ * \file map.c
+ *
+ * \brief Hash-table implementations of a string-to-void* map, and of
* a digest-to-void* map.
**/
diff --git a/src/lib/container/map.h b/src/lib/container/map.h
index ac21c28718..ff71622682 100644
--- a/src/lib/container/map.h
+++ b/src/lib/container/map.h
@@ -6,6 +6,12 @@
#ifndef TOR_MAP_H
#define TOR_MAP_H
+/**
+ * \file map.h
+ *
+ * \brief Headers for map.c.
+ **/
+
#include "lib/testsupport/testsupport.h"
#include "lib/cc/torint.h"
diff --git a/src/lib/container/order.h b/src/lib/container/order.h
index bd23750d54..f0675f347b 100644
--- a/src/lib/container/order.h
+++ b/src/lib/container/order.h
@@ -6,6 +6,12 @@
#ifndef TOR_ORDER_H
#define TOR_ORDER_H
+/**
+ * \file order.h
+ *
+ * \brief Header for order.c.
+ **/
+
#include "lib/cc/compat_compiler.h"
#include "lib/cc/torint.h"
diff --git a/src/lib/container/smartlist.c b/src/lib/container/smartlist.c
index 9025cab9f6..63c50e045d 100644
--- a/src/lib/container/smartlist.c
+++ b/src/lib/container/smartlist.c
@@ -4,9 +4,15 @@
/* See LICENSE for licensing information */
/**
- * \file container.c
- * \brief Implements a smartlist (a resizable array) along
- * with helper functions to use smartlists.
+ * \file smartlist.c
+ *
+ * \brief Higher-level functions for the "smartlist" resizeable array
+ * abstraction.
+ *
+ * The functions declared here use higher-level functionality than those in
+ * smartlist_core.c, and handle things like smartlists of different types,
+ * sorting, searching, heap-structured smartlists, and other convenience
+ * functions.
**/
#include "lib/container/smartlist.h"
diff --git a/src/lib/container/smartlist.h b/src/lib/container/smartlist.h
index 76ecbda0a2..3b19cbfce4 100644
--- a/src/lib/container/smartlist.h
+++ b/src/lib/container/smartlist.h
@@ -6,6 +6,12 @@
#ifndef TOR_SMARTLIST_H
#define TOR_SMARTLIST_H
+/**
+ * \file smartlist.h
+ *
+ * \brief Header for smartlist.c
+ **/
+
#include <stdarg.h>
#include "lib/smartlist_core/smartlist_core.h"
diff --git a/src/lib/crypt_ops/.may_include b/src/lib/crypt_ops/.may_include
index 6ca06f590e..a0fa4ec05c 100644
--- a/src/lib/crypt_ops/.may_include
+++ b/src/lib/crypt_ops/.may_include
@@ -9,7 +9,6 @@ lib/encoding/*.h
lib/fs/*.h
lib/lock/*.h
lib/malloc/*.h
-lib/err/*.h
lib/intmath/*.h
lib/sandbox/*.h
lib/string/*.h
diff --git a/src/lib/crypt_ops/crypto_pwbox.h b/src/lib/crypt_ops/crypto_pwbox.h
index 9ed35a150e..00fabd0913 100644
--- a/src/lib/crypt_ops/crypto_pwbox.h
+++ b/src/lib/crypt_ops/crypto_pwbox.h
@@ -1,6 +1,12 @@
/* Copyright (c) 2014-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file crypto_pwbox.h
+ *
+ * \brief Header for crypto_pwbox.c
+ **/
+
#ifndef CRYPTO_PWBOX_H_INCLUDED_
#define CRYPTO_PWBOX_H_INCLUDED_
@@ -20,4 +26,3 @@ int crypto_unpwbox(uint8_t **out, size_t *outlen_out,
const char *secret, size_t secret_len);
#endif /* !defined(CRYPTO_PWBOX_H_INCLUDED_) */
-
diff --git a/src/lib/crypt_ops/crypto_s2k.h b/src/lib/crypt_ops/crypto_s2k.h
index b270897b68..2429185b52 100644
--- a/src/lib/crypt_ops/crypto_s2k.h
+++ b/src/lib/crypt_ops/crypto_s2k.h
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file crypto_s2k.h
+ *
+ * \brief Header for crypto_s2k.c
+ **/
+
#ifndef TOR_CRYPTO_S2K_H_INCLUDED
#define TOR_CRYPTO_S2K_H_INCLUDED
@@ -70,4 +76,3 @@ STATIC int secret_to_key_compute_key(uint8_t *key_out, size_t key_out_len,
#endif /* defined(CRYPTO_S2K_PRIVATE) */
#endif /* !defined(TOR_CRYPTO_S2K_H_INCLUDED) */
-
diff --git a/src/lib/defs/digest_sizes.h b/src/lib/defs/digest_sizes.h
index f426fff20d..dd772cae07 100644
--- a/src/lib/defs/digest_sizes.h
+++ b/src/lib/defs/digest_sizes.h
@@ -7,6 +7,15 @@
#ifndef TOR_DIGEST_SIZES_H
#define TOR_DIGEST_SIZES_H
+/**
+ * \file digest_sizes.h
+ *
+ * \brief Definitions for common sizes of cryptographic digests.
+ *
+ * Tor uses digests throughout its codebase, even in parts that don't actually
+ * calculate the digests.
+ **/
+
/** Length of the output of our message digest. */
#define DIGEST_LEN 20
/** Length of the output of our second (improved) message digests. (For now
diff --git a/src/lib/encoding/binascii.h b/src/lib/encoding/binascii.h
index 67f9eb0e87..23cbaa7070 100644
--- a/src/lib/encoding/binascii.h
+++ b/src/lib/encoding/binascii.h
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file binascii.h
+ *
+ * \brief Header for binascii.c
+ **/
+
#ifndef TOR_BINASCII_H
#define TOR_BINASCII_H
diff --git a/src/lib/encoding/confline.c b/src/lib/encoding/confline.c
index 7f535b321a..3486b6a82b 100644
--- a/src/lib/encoding/confline.c
+++ b/src/lib/encoding/confline.c
@@ -4,6 +4,17 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file confline.c
+ *
+ * \brief Functions to manipulate a linked list of key-value pairs, of the
+ * type used in Tor's configuration files.
+ *
+ * Tor uses the config_line_t type and its associated serialized format for
+ * human-readable key-value pairs in many places, including its configuration,
+ * its state files, its consensus cache, and so on.
+ **/
+
#include "lib/encoding/confline.h"
#include "lib/encoding/cstring.h"
#include "lib/log/torlog.h"
diff --git a/src/lib/encoding/confline.h b/src/lib/encoding/confline.h
index f03faed5eb..41f1200947 100644
--- a/src/lib/encoding/confline.h
+++ b/src/lib/encoding/confline.h
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file confline.h
+ *
+ * \brief Header for confline.c
+ **/
+
#ifndef TOR_CONFLINE_H
#define TOR_CONFLINE_H
diff --git a/src/lib/encoding/cstring.c b/src/lib/encoding/cstring.c
index 86c17f0d2c..994a52e70c 100644
--- a/src/lib/encoding/cstring.c
+++ b/src/lib/encoding/cstring.c
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file cstring.c
+ *
+ * \brief Decode data that has been written as a C literal.
+ **/
+
#include "lib/encoding/cstring.h"
#include "lib/log/torlog.h"
#include "lib/log/util_bug.h"
diff --git a/src/lib/encoding/cstring.h b/src/lib/encoding/cstring.h
index 3dff5e7f7f..2da109d958 100644
--- a/src/lib/encoding/cstring.h
+++ b/src/lib/encoding/cstring.h
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file cstring.h
+ *
+ * \brief Header for cstring.c
+ **/
+
#ifndef TOR_CSTRING_H
#define TOR_CSTRING_H
diff --git a/src/lib/encoding/keyval.c b/src/lib/encoding/keyval.c
index cffd6f6dbc..53ee776fe7 100644
--- a/src/lib/encoding/keyval.c
+++ b/src/lib/encoding/keyval.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file keyval.c
+ *
+ * \brief Handle data encoded as a key=value pair.
+ **/
+
#include "orconfig.h"
#include "lib/encoding/keyval.h"
#include "lib/log/escape.h"
diff --git a/src/lib/encoding/keyval.h b/src/lib/encoding/keyval.h
index 7458555207..8bf0797627 100644
--- a/src/lib/encoding/keyval.h
+++ b/src/lib/encoding/keyval.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file keyval.h
+ *
+ * \brief Header for keyval.c
+ **/
+
#ifndef TOR_KEYVAL_H
#define TOR_KEYVAL_H
diff --git a/src/lib/encoding/time_fmt.c b/src/lib/encoding/time_fmt.c
index ef60f17e36..ea9c8e9fd1 100644
--- a/src/lib/encoding/time_fmt.c
+++ b/src/lib/encoding/time_fmt.c
@@ -4,6 +4,16 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file time_fmt.c
+ *
+ * \brief Encode and decode time in various formats.
+ *
+ * This module is higher-level than the conversion functions in "wallclock",
+ * and handles a larger variety of types. It converts between different time
+ * formats, and encodes and decodes them from strings.
+ **/
+
#include "lib/encoding/time_fmt.h"
#include "lib/log/torlog.h"
#include "lib/log/escape.h"
diff --git a/src/lib/encoding/time_fmt.h b/src/lib/encoding/time_fmt.h
index 41508ce5e6..2892442adf 100644
--- a/src/lib/encoding/time_fmt.h
+++ b/src/lib/encoding/time_fmt.h
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file time_fmt.h
+ *
+ * \brief Header for time_fmt.c
+ **/
+
#ifndef TOR_TIME_FMT_H
#define TOR_TIME_FMT_H
diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c
index cded6459f7..5f5ecd3c37 100644
--- a/src/lib/err/backtrace.c
+++ b/src/lib/err/backtrace.c
@@ -11,6 +11,10 @@
* family of functions, which are sometimes provided by libc and sometimes
* provided by libexecinfo. We tie into the sigaction() backend in order to
* detect crashes.
+ *
+ * This is one of the lowest-level modules, since nearly everything needs to
+ * be able to log an error. As such, it doesn't call the log module or any
+ * other higher-level modules directly.
*/
#include "orconfig.h"
diff --git a/src/lib/err/backtrace.h b/src/lib/err/backtrace.h
index 7f77428436..70c43484f5 100644
--- a/src/lib/err/backtrace.h
+++ b/src/lib/err/backtrace.h
@@ -4,6 +4,12 @@
#ifndef TOR_BACKTRACE_H
#define TOR_BACKTRACE_H
+/**
+ * \file backtrace.h
+ *
+ * \brief Header for backtrace.c
+ **/
+
#include "orconfig.h"
#include "lib/cc/compat_compiler.h"
diff --git a/src/lib/err/torerr.c b/src/lib/err/torerr.c
index 8d8f694f1d..f9e139f967 100644
--- a/src/lib/err/torerr.c
+++ b/src/lib/err/torerr.c
@@ -9,6 +9,14 @@
*
* \brief Handling code for unrecoverable emergencies, at a lower level
* than the logging code.
+ *
+ * There are plenty of places that things can go wrong in Tor's backend
+ * libraries: the allocator can fail, the locking subsystem can fail, and so
+ * on. But since these subsystems are used themselves by the logging module,
+ * they can't use the logging code directly to report their errors.
+ *
+ * As a workaround, the logging code provides this module with a set of raw
+ * fds to be used for reporting errors in the lowest-level Tor code.
*/
#include "orconfig.h"
diff --git a/src/lib/fdio/fdio.c b/src/lib/fdio/fdio.c
index 21577e1845..afb57e03dd 100644
--- a/src/lib/fdio/fdio.c
+++ b/src/lib/fdio/fdio.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file fdio.c
+ *
+ * \brief Low-level compatibility wrappers for fd-based IO.
+ **/
+
#include "orconfig.h"
#ifdef HAVE_UNISTD_H
diff --git a/src/lib/fdio/fdio.h b/src/lib/fdio/fdio.h
index 0fb3ed1e62..c8f05455b7 100644
--- a/src/lib/fdio/fdio.h
+++ b/src/lib/fdio/fdio.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file fdio.h
+ *
+ * \brief Header for fdio.c
+ **/
+
#ifndef TOR_FDIO_H
#define TOR_FDIO_H
diff --git a/src/lib/fs/conffile.c b/src/lib/fs/conffile.c
index 37bd9f0368..600c7f6b70 100644
--- a/src/lib/fs/conffile.c
+++ b/src/lib/fs/conffile.c
@@ -4,6 +4,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file conffile.h
+ *
+ * \brief Read configuration files from disk, with full `%include` support.
+ **/
+
#include "lib/fs/conffile.h"
#include "lib/container/smartlist.h"
diff --git a/src/lib/fs/conffile.h b/src/lib/fs/conffile.h
index bd8250b002..a926f4ac05 100644
--- a/src/lib/fs/conffile.h
+++ b/src/lib/fs/conffile.h
@@ -7,6 +7,12 @@
#ifndef TOR_CONFFILE_H
#define TOR_CONFFILE_H
+/**
+ * \file conffile.h
+ *
+ * \brief Header for conffile.c
+ **/
+
struct smartlist_t;
struct config_line_t;
diff --git a/src/lib/fs/dir.c b/src/lib/fs/dir.c
index 9f09327d84..cc339f747e 100644
--- a/src/lib/fs/dir.c
+++ b/src/lib/fs/dir.c
@@ -3,6 +3,13 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file dir.c
+ *
+ * \brief Read directories, and create directories with restrictive
+ * permissions.
+ **/
+
#include "lib/fs/dir.h"
#include "lib/fs/path.h"
#include "lib/fs/userdb.h"
diff --git a/src/lib/fs/dir.h b/src/lib/fs/dir.h
index 925211fbd6..61a04e6d58 100644
--- a/src/lib/fs/dir.h
+++ b/src/lib/fs/dir.h
@@ -6,6 +6,12 @@
#ifndef TOR_DIR_H
#define TOR_DIR_H
+/**
+ * \file dir.h
+ *
+ * \brief Header for dir.c
+ **/
+
#include "lib/cc/compat_compiler.h"
#include "lib/testsupport/testsupport.h"
diff --git a/src/lib/fs/files.c b/src/lib/fs/files.c
index 0335f6dc59..4e0a398baa 100644
--- a/src/lib/fs/files.c
+++ b/src/lib/fs/files.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file files.h
+ *
+ * \brief Wrappers for reading and writing data to files on disk.
+ **/
+
#ifdef _WIN32
#include <windows.h>
#endif
diff --git a/src/lib/fs/files.h b/src/lib/fs/files.h
index be4ec485f1..5a12eb8215 100644
--- a/src/lib/fs/files.h
+++ b/src/lib/fs/files.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file files.h
+ *
+ * \brief Header for files.c
+ **/
+
#ifndef TOR_FS_H
#define TOR_FS_H
diff --git a/src/lib/fs/freespace.c b/src/lib/fs/freespace.c
index 926b17dbde..2dbba3c5f8 100644
--- a/src/lib/fs/freespace.c
+++ b/src/lib/fs/freespace.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file freespace.c
+ *
+ * \brief Find the available disk space on the current volume.
+ **/
+
#include "lib/fs/files.h"
#include "lib/cc/torint.h"
diff --git a/src/lib/fs/lockfile.c b/src/lib/fs/lockfile.c
index 3fc9cd4264..972fd5658d 100644
--- a/src/lib/fs/lockfile.c
+++ b/src/lib/fs/lockfile.c
@@ -3,6 +3,13 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file lockfile.c
+ *
+ * \brief Implements lock files to prevent two Tor processes from using the
+ * same data directory at the same time.
+ **/
+
#include "orconfig.h"
#include "lib/fs/files.h"
#include "lib/fs/lockfile.h"
diff --git a/src/lib/fs/lockfile.h b/src/lib/fs/lockfile.h
index 1c5bb023b5..e26349811c 100644
--- a/src/lib/fs/lockfile.h
+++ b/src/lib/fs/lockfile.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file lockfile.h
+ *
+ * \brief Header for lockfile.c
+ **/
+
#ifndef TOR_LOCKFILE_H
#define TOR_LOCKFILE_H
diff --git a/src/lib/fs/mmap.c b/src/lib/fs/mmap.c
index 6d69fd5e78..2d758c1b5f 100644
--- a/src/lib/fs/mmap.c
+++ b/src/lib/fs/mmap.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file mmap.c
+ *
+ * \brief Cross-platform support for mapping files into our address space.
+ **/
+
#include "lib/fs/mmap.h"
#include "lib/fs/files.h"
#include "lib/log/torlog.h"
diff --git a/src/lib/fs/mmap.h b/src/lib/fs/mmap.h
index b0585775f5..8d6ca9a0e2 100644
--- a/src/lib/fs/mmap.h
+++ b/src/lib/fs/mmap.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file mmap.h
+ *
+ * \brief Header for mmap.c
+ **/
+
#ifndef TOR_MMAP_H
#define TOR_MMAP_H
@@ -29,7 +35,7 @@ typedef struct tor_mmap_t {
} tor_mmap_t;
-tor_mmap_t *tor_mmap_file(const char *filename) ATTR_NONNULL((1));
-int tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1));
+tor_mmap_t *tor_mmap_file(const char *filename);
+int tor_munmap_file(tor_mmap_t *handle);
#endif
diff --git a/src/lib/fs/path.c b/src/lib/fs/path.c
index 68cda67765..708ff0505a 100644
--- a/src/lib/fs/path.c
+++ b/src/lib/fs/path.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file path.c
+ *
+ * \brief Manipulate strings that contain filesystem paths.
+ **/
+
#include "lib/fs/path.h"
#include "lib/malloc/util_malloc.h"
#include "lib/log/torlog.h"
diff --git a/src/lib/fs/path.h b/src/lib/fs/path.h
index a3073a99ec..384d1f514f 100644
--- a/src/lib/fs/path.h
+++ b/src/lib/fs/path.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file path.h
+ *
+ * \brief Header for path.c
+ **/
+
#ifndef TOR_PATH_H
#define TOR_PATH_H
diff --git a/src/lib/fs/storagedir.c b/src/lib/fs/storagedir.c
index d013e4550d..1cda2374d8 100644
--- a/src/lib/fs/storagedir.c
+++ b/src/lib/fs/storagedir.c
@@ -1,6 +1,17 @@
/* Copyright (c) 2017-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file storagedir.c
+ *
+ * \brief An abstraction for a directory full of similar files.
+ *
+ * Storagedirs are used by our consensus cache code, and may someday also get
+ * used for unparseable objects. A large part of the need for this type is to
+ * work around the limitations in our sandbox code, where all filenames need
+ * to be registered in advance.
+ **/
+
#include "lib/fs/storagedir.h"
#include "lib/container/smartlist.h"
diff --git a/src/lib/fs/storagedir.h b/src/lib/fs/storagedir.h
index 1ecb1c0a11..58594b4634 100644
--- a/src/lib/fs/storagedir.h
+++ b/src/lib/fs/storagedir.h
@@ -1,6 +1,12 @@
/* Copyright (c) 2017-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file storagedir.h
+ *
+ * \brief Header for storagedir.c
+ **/
+
#ifndef TOR_STORAGEDIR_H
#define TOR_STORAGEDIR_H
diff --git a/src/lib/fs/userdb.c b/src/lib/fs/userdb.c
index b7abbc7813..3d7a9da59d 100644
--- a/src/lib/fs/userdb.c
+++ b/src/lib/fs/userdb.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file userdb.c
+ *
+ * \brief Access the POSIX user database.
+ **/
+
#include "lib/fs/userdb.h"
#ifndef _WIN32
diff --git a/src/lib/fs/userdb.h b/src/lib/fs/userdb.h
index 31c891ede8..3b3ab6ed2b 100644
--- a/src/lib/fs/userdb.h
+++ b/src/lib/fs/userdb.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file userdb.h
+ *
+ * \brief Header for userdb.c
+ **/
+
#ifndef TOR_USERDB_H
#define TOR_USERDB_H
diff --git a/src/lib/fs/winlib.c b/src/lib/fs/winlib.c
index 7a88a841a6..532807c03f 100644
--- a/src/lib/fs/winlib.c
+++ b/src/lib/fs/winlib.c
@@ -3,6 +3,15 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file winlib.c
+ *
+ * \brief Find and load windows system libraries.
+ *
+ * We use this function to dynamically load code at runtime that might not be
+ * available on all versions of Windows that we support.
+ **/
+
#ifdef _WIN32
#include "lib/fs/winlib.h"
diff --git a/src/lib/fs/winlib.h b/src/lib/fs/winlib.h
index f53f046451..5b10b9b78d 100644
--- a/src/lib/fs/winlib.h
+++ b/src/lib/fs/winlib.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file winlib.h
+ *
+ * \brief Header for winlib.c
+ **/
+
#ifndef TOR_WINLIB_H
#define TOR_WINLIB_H
diff --git a/src/lib/intmath/addsub.c b/src/lib/intmath/addsub.c
index 816c5a2bd7..fcfdca6822 100644
--- a/src/lib/intmath/addsub.c
+++ b/src/lib/intmath/addsub.c
@@ -3,6 +3,14 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file addsub.c
+ *
+ * \brief Helpers for addition and subtraction.
+ *
+ * Currently limited to non-wrapping (saturating) addition.
+ **/
+
#include "lib/intmath/addsub.h"
#include "lib/cc/compat_compiler.h"
diff --git a/src/lib/intmath/addsub.h b/src/lib/intmath/addsub.h
index 5277adfa49..5bbc32e4a9 100644
--- a/src/lib/intmath/addsub.h
+++ b/src/lib/intmath/addsub.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file addsub.h
+ *
+ * \brief Header for addsub.c
+ **/
+
#ifndef TOR_INTMATH_ADDSUB_H
#define TOR_INTMATH_ADDSUB_H
diff --git a/src/lib/intmath/bits.c b/src/lib/intmath/bits.c
index 85d901f71b..4b5729e99a 100644
--- a/src/lib/intmath/bits.c
+++ b/src/lib/intmath/bits.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file bits.c
+ *
+ * \brief Count the bits in an integer, manipulate powers of 2, etc.
+ **/
+
#include "lib/intmath/bits.h"
/** Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0. */
diff --git a/src/lib/intmath/bits.h b/src/lib/intmath/bits.h
index 70f855089c..80eebe9358 100644
--- a/src/lib/intmath/bits.h
+++ b/src/lib/intmath/bits.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file bits.h
+ *
+ * \brief Header for bits.c
+ **/
+
#ifndef TOR_INTMATH_BITS_H
#define TOR_INTMATH_BITS_H
diff --git a/src/lib/intmath/cmp.h b/src/lib/intmath/cmp.h
index 627e5d18b4..16952bee3e 100644
--- a/src/lib/intmath/cmp.h
+++ b/src/lib/intmath/cmp.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file cmp.h
+ *
+ * \brief Macro definitions for MIN, MAX, and CLAMP.
+ **/
+
#ifndef TOR_INTMATH_CMP_H
#define TOR_INTMATH_CMP_H
diff --git a/src/lib/intmath/logic.h b/src/lib/intmath/logic.h
index 0510a621dc..b3eabc652e 100644
--- a/src/lib/intmath/logic.h
+++ b/src/lib/intmath/logic.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file logic.h
+ *
+ * \brief Macros for comparing the boolean value of integers.
+ **/
+
#ifndef HAVE_TOR_LOGIC_H
#define HAVE_TOR_LOGIC_H
diff --git a/src/lib/intmath/muldiv.c b/src/lib/intmath/muldiv.c
index 3e627b237a..c5fc689e2d 100644
--- a/src/lib/intmath/muldiv.c
+++ b/src/lib/intmath/muldiv.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file muldiv.c
+ *
+ * \brief Integer math related to multiplication, division, and rounding.
+ **/
+
#include "lib/intmath/muldiv.h"
#include "lib/err/torerr.h"
diff --git a/src/lib/intmath/muldiv.h b/src/lib/intmath/muldiv.h
index de76d9eb68..45b896922f 100644
--- a/src/lib/intmath/muldiv.h
+++ b/src/lib/intmath/muldiv.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file muldiv.h
+ *
+ * \brief Header for muldiv.c
+ **/
+
#ifndef TOR_INTMATH_MULDIV_H
#define TOR_INTMATH_MULDIV_H
diff --git a/src/lib/intmath/weakrng.c b/src/lib/intmath/weakrng.c
index 2ecab97cc1..36cf5fb0aa 100644
--- a/src/lib/intmath/weakrng.c
+++ b/src/lib/intmath/weakrng.c
@@ -3,6 +3,15 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file weakrng.c
+ *
+ * \brief A weak but fast PRNG based on a linear congruential generator.
+ *
+ * We don't want to use the platform random(), since some of them are even
+ * worse than this.
+ **/
+
#include "lib/intmath/weakrng.h"
#include "lib/err/torerr.h"
diff --git a/src/lib/intmath/weakrng.h b/src/lib/intmath/weakrng.h
index e5a88b30fe..679bf2449c 100644
--- a/src/lib/intmath/weakrng.h
+++ b/src/lib/intmath/weakrng.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file weakrng.h
+ *
+ * \brief Header for weakrng.c
+ **/
+
#ifndef TOR_WEAKRNG_H
#define TOR_WEAKRNG_H
diff --git a/src/lib/lock/compat_mutex.c b/src/lib/lock/compat_mutex.c
index e0f6224a83..bfab6dd29b 100644
--- a/src/lib/lock/compat_mutex.c
+++ b/src/lib/lock/compat_mutex.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file compat_mutex.c
+ *
+ * \brief Portable wrapper for platform mutex implementations.
+ **/
+
#include "lib/lock/compat_mutex.h"
#include "lib/malloc/util_malloc.h"
diff --git a/src/lib/lock/compat_mutex.h b/src/lib/lock/compat_mutex.h
index 92978086ac..f467aa5dba 100644
--- a/src/lib/lock/compat_mutex.h
+++ b/src/lib/lock/compat_mutex.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file compat_mutex.h
+ *
+ * \brief Header for compat_mutex.c
+ **/
+
#ifndef TOR_COMPAT_MUTEX_H
#define TOR_COMPAT_MUTEX_H
diff --git a/src/lib/lock/compat_mutex_pthreads.c b/src/lib/lock/compat_mutex_pthreads.c
index 390da4fb81..983abf5ae5 100644
--- a/src/lib/lock/compat_mutex_pthreads.c
+++ b/src/lib/lock/compat_mutex_pthreads.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file compat_mutex_pthreads.c
+ *
+ * \brief Implement the tor_mutex API using pthread_mutex_t.
+ **/
+
#include "lib/lock/compat_mutex.h"
#include "lib/cc/compat_compiler.h"
#include "lib/err/torerr.h"
diff --git a/src/lib/lock/compat_mutex_winthreads.c b/src/lib/lock/compat_mutex_winthreads.c
index 32be288c7f..22c1edeed4 100644
--- a/src/lib/lock/compat_mutex_winthreads.c
+++ b/src/lib/lock/compat_mutex_winthreads.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file compat_mutex_winthreads.c
+ *
+ * \brief Implement the tor_mutex API using CRITICAL_SECTION.
+ **/
+
#include "lib/lock/compat_mutex.h"
#include "lib/err/torerr.h"
diff --git a/src/lib/malloc/util_malloc.h b/src/lib/malloc/util_malloc.h
index 88ecc04530..a1e9531176 100644
--- a/src/lib/malloc/util_malloc.h
+++ b/src/lib/malloc/util_malloc.h
@@ -21,13 +21,13 @@ void *tor_malloc_zero_(size_t size) ATTR_MALLOC;
void *tor_calloc_(size_t nmemb, size_t size) ATTR_MALLOC;
void *tor_realloc_(void *ptr, size_t size);
void *tor_reallocarray_(void *ptr, size_t size1, size_t size2);
-char *tor_strdup_(const char *s) ATTR_MALLOC ATTR_NONNULL((1));
+char *tor_strdup_(const char *s) ATTR_MALLOC;
char *tor_strndup_(const char *s, size_t n)
- ATTR_MALLOC ATTR_NONNULL((1));
+ ATTR_MALLOC;
void *tor_memdup_(const void *mem, size_t len)
- ATTR_MALLOC ATTR_NONNULL((1));
+ ATTR_MALLOC;
void *tor_memdup_nulterm_(const void *mem, size_t len)
- ATTR_MALLOC ATTR_NONNULL((1));
+ ATTR_MALLOC;
void tor_free_(void *mem);
/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup,
diff --git a/src/lib/math/fp.c b/src/lib/math/fp.c
index d1c4428251..d5989db637 100644
--- a/src/lib/math/fp.c
+++ b/src/lib/math/fp.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file fp.c
+ *
+ * \brief Basic floating-point compatibility and convenience code.
+ **/
+
#include "orconfig.h"
#include "lib/math/fp.h"
diff --git a/src/lib/math/fp.h b/src/lib/math/fp.h
index b35c18a1c7..e27b8f8d80 100644
--- a/src/lib/math/fp.h
+++ b/src/lib/math/fp.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file fp.h
+ *
+ * \brief Header for fp.c
+ **/
+
#ifndef TOR_FP_H
#define TOR_FP_H
diff --git a/src/lib/math/laplace.c b/src/lib/math/laplace.c
index 8e45a1fb33..6b33b46902 100644
--- a/src/lib/math/laplace.c
+++ b/src/lib/math/laplace.c
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file laplace.c
+ *
+ * \brief Implements a Laplace distribution, used for adding noise to things.
+ **/
+
#include "orconfig.h"
#include "lib/math/laplace.h"
#include "lib/math/fp.h"
diff --git a/src/lib/math/laplace.h b/src/lib/math/laplace.h
index b22862e64a..62d698e369 100644
--- a/src/lib/math/laplace.h
+++ b/src/lib/math/laplace.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file laplace.h
+ *
+ * \brief Header for laplace.c
+ **/
+
#ifndef TOR_LAPLACE_H
#define TOR_LAPLACE_H
diff --git a/src/lib/memarea/memarea.c b/src/lib/memarea/memarea.c
index 7fe3825723..2d510a51ac 100644
--- a/src/lib/memarea/memarea.c
+++ b/src/lib/memarea/memarea.c
@@ -1,7 +1,9 @@
/* Copyright (c) 2008-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
-/** \file memarea.c
+/**
+ * \file memarea.c
+ *
* \brief Implementation for memarea_t, an allocator for allocating lots of
* small objects that will be freed all at once.
*/
diff --git a/src/lib/memarea/memarea.h b/src/lib/memarea/memarea.h
index e52f5a1be7..4978b54162 100644
--- a/src/lib/memarea/memarea.h
+++ b/src/lib/memarea/memarea.h
@@ -1,6 +1,11 @@
/* Copyright (c) 2008-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
-/* Tor dependencies */
+
+/**
+ * \file memarea.h
+ *
+ * \brief Header for memarea.c
+ **/
#ifndef TOR_MEMAREA_H
#define TOR_MEMAREA_H
diff --git a/src/lib/meminfo/meminfo.c b/src/lib/meminfo/meminfo.c
index 34b4ad3b5d..b5a74ce624 100644
--- a/src/lib/meminfo/meminfo.c
+++ b/src/lib/meminfo/meminfo.c
@@ -3,6 +3,13 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file meminfo.c
+ *
+ * \brief Functions to query total memory, and access meta-information about
+ * the allocator.
+ **/
+
#include "lib/meminfo/meminfo.h"
#include "lib/cc/compat_compiler.h"
diff --git a/src/lib/meminfo/meminfo.h b/src/lib/meminfo/meminfo.h
index a970e992f0..b67d235559 100644
--- a/src/lib/meminfo/meminfo.h
+++ b/src/lib/meminfo/meminfo.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file meminfo.h
+ *
+ * \brief Header for meminfo.c
+ **/
+
#ifndef TOR_MEMINFO_H
#define TOR_MEMINFO_H
diff --git a/src/lib/net/alertsock.c b/src/lib/net/alertsock.c
index c6ea1551f8..340f9513fb 100644
--- a/src/lib/net/alertsock.c
+++ b/src/lib/net/alertsock.c
@@ -3,6 +3,17 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file alertsock.c
+ *
+ * \brief Use a socket to alert the main thread from a worker thread.
+ *
+ * Because our main loop spends all of its time in select, epoll, kqueue, or
+ * etc, we need a way to wake up the main loop from another thread. This code
+ * tries to provide the fastest reasonable way to do that, depending on our
+ * platform.
+ **/
+
#include "orconfig.h"
#include "lib/net/alertsock.h"
#include "lib/net/socket.h"
diff --git a/src/lib/net/alertsock.h b/src/lib/net/alertsock.h
index 026a15cad0..5dfe53a2a0 100644
--- a/src/lib/net/alertsock.h
+++ b/src/lib/net/alertsock.h
@@ -3,6 +3,12 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+/**
+ * \file alertsock.h
+ *
+ * \brief Header for alertsock.c
+ **/
+
#ifndef TOR_ALERTSOCK_H
#define TOR_ALERTSOCK_H
diff --git a/src/lib/net/buffers_net.h b/src/lib/net/buffers_net.h
index d03b61376e..417f6f9413 100644
--- a/src/lib/net/buffers_net.h
+++ b/src/lib/net/buffers_net.h
@@ -5,8 +5,9 @@
/* See LICENSE for licensing information */
/**
- * \file buffers.h
- * \brief Header file for buffers.c.
+ * \file buffers_net.h
+ *
+ * \brief Header file for buffers_net.c.
**/
#ifndef TOR_BUFFERS_NET_H
diff --git a/src/lib/process/.may_include b/src/lib/process/.may_include
index c02e7fddb2..05414d2a96 100644
--- a/src/lib/process/.may_include
+++ b/src/lib/process/.may_include
@@ -4,6 +4,7 @@ lib/cc/*.h
lib/container/*.h
lib/ctime/*.h
lib/err/*.h
+lib/intmath/*.h
lib/fs/*.h
lib/log/*.h
lib/malloc/*.h
diff --git a/src/lib/string/compat_string.h b/src/lib/string/compat_string.h
index 24cd0f8b11..34490bce07 100644
--- a/src/lib/string/compat_string.h
+++ b/src/lib/string/compat_string.h
@@ -13,9 +13,20 @@
/* ===== String compatibility */
#ifdef _WIN32
-/* Windows names string functions differently from most other platforms. */
-#define strncasecmp _strnicmp
-#define strcasecmp _stricmp
+/* Windows doesn't have str(n)casecmp, but mingw defines it: only define it
+ * ourselves if it's missing. */
+#ifndef HAVE_STRNCASECMP
+static inline int strncasecmp(const char *a, const char *b, size_t n);
+static inline int strncasecmp(const char *a, const char *b, size_t n) {
+ return strncmpi(a,b);
+}
+#endif
+#ifndef HAVE_STRCASECMP
+static inline int strcasecmp(const char *a, const char *b, size_t n);
+static inline int strcasecmp(const char *a, const char *b, size_t n) {
+ return strcmpi(a,b);
+}
+#endif
#endif
#if defined __APPLE__
@@ -30,10 +41,10 @@
#endif /* defined __APPLE__ */
#ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
+size_t strlcat(char *dst, const char *src, size_t siz);
#endif
#ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
+size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
char *tor_strtok_r_impl(char *str, const char *sep, char **lasts);
diff --git a/src/lib/string/printf.h b/src/lib/string/printf.h
index 2f46206545..69b724379a 100644
--- a/src/lib/string/printf.h
+++ b/src/lib/string/printf.h
@@ -13,9 +13,9 @@
#include <stddef.h>
int tor_snprintf(char *str, size_t size, const char *format, ...)
- CHECK_PRINTF(3,4) ATTR_NONNULL((1,3));
+ CHECK_PRINTF(3,4);
int tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
- CHECK_PRINTF(3,0) ATTR_NONNULL((1,3));
+ CHECK_PRINTF(3,0);
int tor_asprintf(char **strp, const char *fmt, ...)
CHECK_PRINTF(2,3);
diff --git a/src/lib/string/util_string.h b/src/lib/string/util_string.h
index bdc2e77cea..75407d5ffa 100644
--- a/src/lib/string/util_string.h
+++ b/src/lib/string/util_string.h
@@ -12,29 +12,29 @@
#include <stddef.h>
const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
- size_t nlen) ATTR_NONNULL((1,3));
+ size_t nlen);
const void *tor_memstr(const void *haystack, size_t hlen,
- const char *needle) ATTR_NONNULL((1,3));
+ const char *needle);
int tor_mem_is_zero(const char *mem, size_t len);
int tor_digest_is_zero(const char *digest);
int tor_digest256_is_zero(const char *digest);
/** Allowable characters in a hexadecimal string. */
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
-void tor_strlower(char *s) ATTR_NONNULL((1));
-void tor_strupper(char *s) ATTR_NONNULL((1));
-int tor_strisprint(const char *s) ATTR_NONNULL((1));
-int tor_strisnonupper(const char *s) ATTR_NONNULL((1));
+void tor_strlower(char *s);
+void tor_strupper(char *s);
+int tor_strisprint(const char *s);
+int tor_strisnonupper(const char *s);
int tor_strisspace(const char *s);
int strcmp_opt(const char *s1, const char *s2);
-int strcmpstart(const char *s1, const char *s2) ATTR_NONNULL((1,2));
-int strcmp_len(const char *s1, const char *s2, size_t len) ATTR_NONNULL((1,2));
-int strcasecmpstart(const char *s1, const char *s2) ATTR_NONNULL((1,2));
-int strcmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
-int strcasecmpend(const char *s1, const char *s2) ATTR_NONNULL((1,2));
+int strcmpstart(const char *s1, const char *s2);
+int strcmp_len(const char *s1, const char *s2, size_t len);
+int strcasecmpstart(const char *s1, const char *s2);
+int strcmpend(const char *s1, const char *s2);
+int strcasecmpend(const char *s1, const char *s2);
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
-void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
+void tor_strstrip(char *s, const char *strip);
const char *eat_whitespace(const char *s);
const char *eat_whitespace_eos(const char *s, const char *eos);
diff --git a/src/lib/tls/.may_include b/src/lib/tls/.may_include
index 1a4b8ca521..ca7cb455e4 100644
--- a/src/lib/tls/.may_include
+++ b/src/lib/tls/.may_include
@@ -1,16 +1,16 @@
orconfig.h
+
lib/arch/*.h
lib/cc/*.h
-lib/ctime/*.h
lib/container/*.h
lib/crypt_ops/*.h
-lib/intmath/*.h
+lib/ctime/*.h
lib/encoding/*.h
-lib/err/*.h
+lib/intmath/*.h
+lib/log/*.h
lib/net/*.h
lib/string/*.h
lib/testsupport/testsupport.h
lib/tls/*.h
-lib/log/*.h
ciphers.inc
diff --git a/src/test/hs_ntor_ref.py b/src/test/hs_ntor_ref.py
index f892cd8f84..0c5756ad73 100644
--- a/src/test/hs_ntor_ref.py
+++ b/src/test/hs_ntor_ref.py
@@ -234,8 +234,11 @@ Utilities for communicating with the little-t-tor ntor wrapper to conduct the
integration tests
"""
-PROG = b"./src/test/test-hs-ntor-cl"
-enhex=lambda s: binascii.b2a_hex(s)
+PROG = "./src/test/test-hs-ntor-cl"
+if sys.version_info[0] >= 3:
+ enhex=lambda s: binascii.b2a_hex(s).decode("ascii")
+else:
+ enhex=lambda s: binascii.b2a_hex(s)
dehex=lambda s: binascii.a2b_hex(s.strip())
def tor_client1(intro_auth_pubkey_str, intro_enc_pubkey,
diff --git a/src/test/ntor_ref.py b/src/test/ntor_ref.py
index 9294827e13..56e97ece36 100755
--- a/src/test/ntor_ref.py
+++ b/src/test/ntor_ref.py
@@ -336,13 +336,16 @@ def test_tor():
Call the test-ntor-cl command-line program to make sure we can
interoperate with Tor's ntor program
"""
- enhex=lambda s: binascii.b2a_hex(s)
+ if sys.version_info[0] >= 3:
+ enhex=lambda s: binascii.b2a_hex(s).decode("ascii")
+ else:
+ enhex=lambda s: binascii.b2a_hex(s)
dehex=lambda s: binascii.a2b_hex(s.strip())
- PROG = b"./src/test/test-ntor-cl"
+ PROG = "./src/test/test-ntor-cl"
def tor_client1(node_id, pubkey_B):
" returns (msg, state) "
- p = subprocess.Popen([PROG, b"client1", enhex(node_id),
+ p = subprocess.Popen([PROG, "client1", enhex(node_id),
enhex(pubkey_B.serialize())],
stdout=subprocess.PIPE)
return map(dehex, p.stdout.readlines())