From: Phillip Wood Date: Thu, 4 Oct 2018 10:07:42 +0000 (+0100) Subject: diff --color-moved-ws: fix out of bounds string access X-Git-Tag: v2.20.0-rc0~153^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf074a9b0e589bad8e6b210ac1e3a4714463f7db;p=thirdparty%2Fgit.git 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 Reviewed-by: Stefan Beller Signed-off-by: Junio C Hamano --- diff --git a/diff.c b/diff.c index 566419dc75..6f12212134 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;