summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-01-18 08:13:48 -0500
committerNick Mathewson <nickm@torproject.org>2018-01-18 08:13:48 -0500
commit44388757c44834d63614c4e13cf88931992afc2a (patch)
tree13fdd2bbfbc09643ec390e7bebd142a1ab989f21
parent4e653ac2cab08edf0e811ae38204e61bc13f1871 (diff)
parentf406b9df0533c9730b4537b39f3a7f8d232f3558 (diff)
downloadtor-44388757c44834d63614c4e13cf88931992afc2a.tar.gz
tor-44388757c44834d63614c4e13cf88931992afc2a.zip
Merge branch 'maint-0.3.1' into maint-0.3.2
-rw-r--r--changes/bug24826_0314
-rw-r--r--src/or/consdiff.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/changes/bug24826_031 b/changes/bug24826_031
new file mode 100644
index 0000000000..3d4a66184a
--- /dev/null
+++ b/changes/bug24826_031
@@ -0,0 +1,4 @@
+ o Minor bugfixes (performance, fragile-hardening):
+ - Improve the performance of our consensus-diff application code when Tor
+ is built with the --enable-fragile-hardening option set. Fixes bug
+ 24826; bugfix on 0.3.1.1-alpha.
diff --git a/src/or/consdiff.c b/src/or/consdiff.c
index 1baa11897c..deaf465fe7 100644
--- a/src/or/consdiff.c
+++ b/src/or/consdiff.c
@@ -1285,8 +1285,11 @@ consdiff_apply_diff(const smartlist_t *cons1,
STATIC int
consensus_split_lines(smartlist_t *out, const char *s, memarea_t *area)
{
+ const char *end_of_str = s + strlen(s);
+ tor_assert(*end_of_str == '\0');
+
while (*s) {
- const char *eol = strchr(s, '\n');
+ const char *eol = memchr(s, '\n', end_of_str - s);
if (!eol) {
/* File doesn't end with newline. */
return -1;