aboutsummaryrefslogtreecommitdiff
path: root/src/lib
AgeCommit message (Collapse)Author
2020-07-14Strip '\r' characters when reading text files on Unix.Alexander Færøy
This patch ensures that we strip "\r" characters on both Windows as well as Unix when we read text files. This should prevent the issue where some Tor state files have been moved from a Windows machine, and thus contains CRLF line ending, to a Unix machine where only \n is needed. We add a test-case to ensure that we handle this properly on all our platforms. See: https://bugs.torproject.org/tpo/core/tor/33781
2020-07-09Merge branch 'trove_2020_001_035' into maint-0.3.5Nick Mathewson
2020-07-07Resolve a compiler warning from a 32-bit signed/unsigned comparisonNick Mathewson
This warning only affects platforms (like win32) with 32-bit time_t. Fixes bug 40028; bugfix on 0.3.2.8-rc.
2020-07-06Use ((x + 7) >> 3) instead of (x >> 3) when converting from bits to bytes.Alexander Færøy
This patch changes our bits-to-bytes conversion logic in the NSS implementation of `tor_tls_cert_matches_key()` from using (x >> 3) to ((x + 7) >> 3) since DER bit-strings are allowed to contain a number of bits that is not a multiple of 8. Additionally, we add a comment on why we cannot use the `DER_ConvertBitString()` macro from NSS, as we would potentially apply the bits-to-bytes conversion logic twice, which would lead to an insignificant amount of bytes being compared in `SECITEM_ItemsAreEqual()` and thus turn the logic into being a prefix match instead of a full match. The `DER_ConvertBitString()` macro is defined in NSS as: /* ** Macro to convert der decoded bit string into a decoded octet ** string. All it needs to do is fiddle with the length code. */ #define DER_ConvertBitString(item) \ { \ (item)->len = ((item)->len + 7) >> 3; \ } Thanks to Taylor Yu for spotting this problem. This patch is part of the fix for TROVE-2020-001. See: https://bugs.torproject.org/33119
2020-07-06Add constness to length variables in `tor_tls_cert_matches_key`.Alexander Færøy
We add constness to `peer_info_orig_len` and `cert_info_orig_len` in `tor_tls_cert_matches_key` to ensure that we don't accidentally alter the variables. This patch is part of the fix for TROVE-2020-001. See: https://bugs.torproject.org/33119
2020-07-06Fix out-of-bound memory read in `tor_tls_cert_matches_key()` for NSS.Alexander Færøy
This patch fixes an out-of-bound memory read in `tor_tls_cert_matches_key()` when Tor is compiled to use Mozilla's NSS instead of OpenSSL. The NSS library stores some length fields in bits instead of bytes, but the comparison function found in `SECITEM_ItemsAreEqual()` needs the length to be encoded in bytes. This means that for a 140-byte, DER-encoded, SubjectPublicKeyInfo struct (with a 1024-bit RSA public key in it), we would ask `SECITEM_ItemsAreEqual()` to compare the first 1120 bytes instead of 140 (140bytes * 8bits = 1120bits). This patch fixes the issue by converting from bits to bytes before calling `SECITEM_ItemsAreEqual()` and convert the `len`-fields back to bits before we leave the function. This patch is part of the fix for TROVE-2020-001. See: https://bugs.torproject.org/33119
2020-06-30Merge branch 'tor-github/pr/1785' into maint-0.3.5Alexander Færøy
2020-06-30Merge remote-tracking branch 'nickm-github/bug32884_035' into maint-0.3.5Alexander Færøy
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;
2020-05-06Remove an incorrect "Fall through" comment.Nick Mathewson
2020-05-06address.c: add a single (harmless) missing break;Nick Mathewson
2020-05-06Add a fallthrough macro.Nick Mathewson
This macro defers to __attribute__((fallthrough)) on GCC (and clang). Previously we had been using GCC's magic /* fallthrough */ comments, but clang very sensibly doesn't accept those. Since not all compiler recognize it, we only define it when our configure script detects that it works. Part of a fix for 34078.
2020-03-18Port rsa_private_key_too_long() to work on OpenSSL 1.1.0.Nick Mathewson
2020-03-17Merge branch 'trove_2020_002_035' into maint-0.3.5Nick Mathewson
2020-03-17Trivial bugfixes found during TROVE investigation.George Kadianakis
2020-03-17Use >= consistently with max_bits.Nick Mathewson
2020-03-17Extract key length check into a new function, and check more fields.Nick Mathewson
In the openssl that I have, it should be safe to only check the size of n. But if I'm wrong, or if other openssls work differently, we should check whether any of the fields are too large. Issue spotted by Teor.
2020-03-14Fix memory leak in crypto_pk_asn1_decode_private.Nick Mathewson
(Deep, deep thanks to Taylor for reminding me to test this!)
2020-03-14Revise TROVE-2020-002 fix to work on older OpenSSL versions.Nick Mathewson
Although OpenSSL before 1.1.1 is no longer supported, it's possible that somebody is still using it with 0.3.5, so we probably shouldn't break it with this fix.
2020-03-13Merge remote-tracking branch 'tor-github/pr/1693/head' into maint-0.3.5Nick Mathewson
2020-03-11pem_decode(): Tolerate CRLF line endingsNick Mathewson
Fixes bug 33032; bugfix on 0.3.5.1-alpha when we introduced our own PEM decoder.
2020-02-05When parsing, reject >1024-bit RSA private keys sooner.Nick Mathewson
Private-key validation is fairly expensive for long keys in openssl, so we need to avoid it sooner.
2020-01-30Merge remote-tracking branch 'tor-github/pr/1614' into maint-0.3.5teor
2020-01-29Change BUG() messages in buf_flush_to_tls() to IF_BUG_ONCE()Nick Mathewson
We introduced these BUG() checks in b0ddaac07428a06 to prevent a recurrence of bug 23690. But there's a report of the BUG() message getting triggered and filling up the disk. Let's change it to IF_BUG_ONCE(). Fixes bug 33093; bugfix on 0.3.2.2-alpha.
2020-01-16Merge remote-tracking branch 'tor-github/pr/1513' into maint-0.3.5teor
2020-01-06When initializing pthreads, always set the main thread.Nick Mathewson
Fixes bug 32884. This is a bugfix on 0.3.3.1-alpha, when we started allowing restart-in-process with tor_api.h.
2019-12-17Correct how we use libseccompPeter Gerber
This fixes a startup crash with libseccomp v2.4.0 if Sandbox is set to 1.
2019-12-05Merge remote-tracking branch 'tor-github/pr/1277' into maint-0.3.5teor
2019-11-25Merge remote-tracking branch 'tor-github/pr/1394' into maint-0.3.5teor
2019-11-06Do not try to shut down the event loop when it is not initialized.Nick Mathewson
Doing so caused us to crash in some unusual circumstances, such as using --verify-config to verify a configuration that failed during the options_act() stage. Fixes bug 32407; bugfix on 0.3.3.1-alpha.
2019-10-04tls: Log TLS read buffer length bugs onceteor
Rather than filling the logs with similar warnings. Fixes bug 31939; bugfix on 0.3.0.4-rc.
2019-09-23Fix bug when %including folder with comment only files. #31408Daniel Pinto
When processing a %included folder, a bug caused the pointer to the last element of the options list to be set to NULL when processing a file with only comments or whitepace. This could cause options from other files on the same folder to be discarded depending on the lines after the affected %include.
2019-09-17Merge remote-tracking branch 'tor-github/pr/1307' into maint-0.3.5Nick Mathewson
2019-09-10fp.c: Suppress float-conversion warnings on FreeBSD.Nick Mathewson
We used to do this on Windows only, but it appears to affect multiple platforms when building with certain versions of GCC, and a common pattern for defining the floating-point classifier functions. Fixes part of 31687. I'm calling this a bugfux on 31687, when we started suppressing these warnings on Windows.
2019-09-09build: The <sys/sysctl.h> is now deprecated on LinuxDavid Goulet
Closes #31673
2019-09-04backtrace: Check the return values of snprintf() and strncpy()teor
We can't use strlcat() or strlcpy() in torerr, because they are defined in string/compat_string.h on some platforms, and string uses torerr. Part of 31571.
2019-08-30torerr: Try harder to flush raw assert messages before process terminationteor
Some platforms (macOS, maybe others?) can swallow the last write before an abort. This issue is probably caused by a race condition between write buffer cache flushing, and process termination. So we write an extra newline, to make sure that the message always gets through. Fixes bug 31571; bugfix on 0.3.5.1-alpha.
2019-08-30torerr: Log the Tor backtrace version when a raw assertion failsteor
Part of 31571.
2019-08-30backtrace: Log the Tor backtrace version whenever we log a backtraceteor
Previously, we just logged it in the crash handler. Part of 31571.
2019-08-30backtrace: Always set a backtrace Tor versionteor
We want to report the tor version, even on platforms that don't have backtrace support (like Android). This commit stores the backtrace Tor version, regardless of USE_BACKTRACE. Preparation for 31571.
2019-08-12Merge remote-tracking branch 'tor-github/pr/952' into maint-0.3.5teor
2019-08-12Merge remote-tracking branch 'tor-github/pr/951' into maint-0.3.5teor
2019-08-12Merge remote-tracking branch 'tor-github/pr/911' into maint-0.3.5teor
2019-08-09Merge remote-tracking branch 'tor-github/pr/1054' into maint-0.3.5teor
2019-08-09Merge remote-tracking branch 'tor-github/pr/920' into maint-0.3.5teor
2019-08-09Merge remote-tracking branch 'tor-github/pr/763' into maint-0.3.5teor
2019-08-08Merge branch 'ticket31374_029' into ticket31374_035Nick Mathewson
2019-05-29Merge branch 'ticket30561_029' into ticket30561_035Nick Mathewson
2019-04-17Do not warn about compatible OpenSSL upgradesBernhard M. Wiedemann
When releasing OpenSSL patch-level maintenance updates, we do not want to rebuild binaries using it. And since they guarantee ABI stability, we do not have to. Without this patch, warning messages were produced that confused users: https://bugzilla.opensuse.org/show_bug.cgi?id=1129411 Fixes bug 30190; bugfix on 0.2.4.2-alpha commit 7607ad2bec Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
2019-04-15Use a tor_abort_() wrapper in our util_bug.h macrosNick Mathewson
Previously, our use of abort() would break anywhere that we didn't include stdlib.h. This was especially troublesome in case where tor_assert_nonfatal() was used with ALL_BUGS_ARE_FATAL, since that one seldom gets tested. As an alternative, we could have just made this header include stdlib.h. But that seems bloaty. Fixes bug 30189; bugfix on 0.3.4.1-alpha.