diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2017-04-17 06:46:23 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2017-04-17 06:49:27 +0200 |
commit | 459643502b8958b44852d304cd1846d027628fc6 (patch) | |
tree | c483d8d6dd12eeaa075660e736c9daaf031a82cd /src/or/consdiff.c | |
parent | b081a7ed21ae729f6e195715e130edaca3e0b7fe (diff) | |
download | tor-459643502b8958b44852d304cd1846d027628fc6.tar.gz tor-459643502b8958b44852d304cd1846d027628fc6.zip |
Don't accept ranges for add commands in consdiff
Fixes ticket #21963
Diffstat (limited to 'src/or/consdiff.c')
-rw-r--r-- | src/or/consdiff.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/or/consdiff.c b/src/or/consdiff.c index d2a2af1b5f..3481c8f9f1 100644 --- a/src/or/consdiff.c +++ b/src/or/consdiff.c @@ -795,6 +795,7 @@ apply_ed_diff(const smartlist_t *cons1, const smartlist_t *diff, diff_line[diff_cdline->len] = 0; const char *ptr = diff_line; int start = 0, end = 0; + int had_range = 0; if (get_linenum(&ptr, &start) < 0) { log_warn(LD_CONSDIFF, "Could not apply consensus diff because " "an ed command was missing a line number."); @@ -802,6 +803,7 @@ apply_ed_diff(const smartlist_t *cons1, const smartlist_t *diff, } if (*ptr == ',') { /* Two-item range */ + had_range = 1; ++ptr; if (get_linenum(&ptr, &end) < 0) { log_warn(LD_CONSDIFF, "Could not apply consensus diff because " @@ -850,6 +852,13 @@ apply_ed_diff(const smartlist_t *cons1, const smartlist_t *diff, goto error_cleanup; } + /* 'a' commands are not allowed to have ranges. */ + if (had_range && action == 'a') { + log_warn(LD_CONSDIFF, "Could not apply consensus diff because " + "it wanted to add lines after a range."); + goto error_cleanup; + } + /* Add unchanged lines. */ for (; j && j > end; --j) { cdline_t *cons_line = smartlist_get(cons1, j-1); |