1
0
mirror of https://github.com/git/git.git synced 2024-09-24 12:41:31 +02:00

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>
This commit is contained in:
Phillip Wood 2018-10-04 11:07:42 +01:00 committed by Junio C Hamano
parent 74d156f4a1
commit cf074a9b0e

2
diff.c
View File

@ -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;