diff options
Diffstat (limited to 'src/or/consdiff.c')
-rw-r--r-- | src/or/consdiff.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/or/consdiff.c b/src/or/consdiff.c index 7e3d6749f6..c0fe979b60 100644 --- a/src/or/consdiff.c +++ b/src/or/consdiff.c @@ -671,7 +671,7 @@ gen_ed_diff(const smartlist_t *cons1, const smartlist_t *cons2, */ i1=len1-1, i2=len2-1; char buf[128]; - while (i1 > 0 || i2 > 0) { + while (i1 >= 0 || i2 >= 0) { int start1x, start2x, end1, end2, added, deleted; @@ -798,6 +798,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."); @@ -805,6 +806,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 " @@ -853,6 +855,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); |