]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff --color-moved-ws: fix out of bounds string access
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 4 Oct 2018 10:07:42 +0000 (11:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Oct 2018 05:48:07 +0000 (22:48 -0700)
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>
diff.c

diff --git a/diff.c b/diff.c
index 566419dc7539ea0428dd1a1ba267e6124e055377..6f122121344b6043fbe3d996777f6766bfaafb9a 100644 (file)
--- 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;