summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2018-10-04 10:07:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-05 05:48:07 (GMT)
commitcf074a9b0e589bad8e6b210ac1e3a4714463f7db (patch)
tree3e82fe484e9cad95389df5ec3b688ddb1aa50038 /diff.c
parent74d156f4a1b1d563b422127ee347eaa348973a0c (diff)
downloadgit-cf074a9b0e589bad8e6b210ac1e3a4714463f7db.zip
git-cf074a9b0e589bad8e6b210ac1e3a4714463f7db.tar.gz
git-cf074a9b0e589bad8e6b210ac1e3a4714463f7db.tar.bz2
diff --color-moved-ws: fix out of bounds string access
When adjusting the start of the string to take account of the change in indentation the code was not checking that the string being adjusted was in fact longer than the indentation change. This was detected by asan. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 566419d..6f12212 100644
--- a/diff.c
+++ b/diff.c
@@ -865,7 +865,7 @@ static int cmp_in_block_with_wsd(const struct diff_options *o,
al -= wslen;
}
- if (strcmp(a, c))
+ if (al != cl || memcmp(a, c, al))
return 1;
return 0;