From: Phillip Wood <phillip.wood@talktalk.net>
To: Stefan Beller <sbeller@google.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Cc: git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/5] diff --color-moved-ws: fix out of bounds string access
Date: Wed, 3 Oct 2018 10:40:32 +0100 [thread overview]
Message-ID: <ea197dba-bb51-0dde-bd2b-84709ce81a51@talktalk.net> (raw)
In-Reply-To: <CAGZ79kYu9enUT=yL8wfM9quYYz1fs5OU4Wcvci9ZVPPdXkY6gA@mail.gmail.com>
On 02/10/2018 19:58, Stefan Beller wrote:
> On Tue, Oct 2, 2018 at 10:55 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
>>
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> 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>
>> ---
>> diff.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/diff.c b/diff.c
>> index 5a08d64497..0096bdc339 100644
>> --- a/diff.c
>> +++ b/diff.c
>> @@ -841,7 +841,7 @@ static int cmp_in_block_with_wsd(const struct diff_options *o,
>> al -= wslen;
>> }
>>
>> - if (strcmp(a, c))
>> + if (al < 0 || al != cl || memcmp(a, c, al))
>
> If (al < 0) then al != cl, so I would think we could drop the first
> part, and only check with al != cl || memcmp
Yes, I couldn't make up my mind weather to add the al < 0 or not but of
course only one of the lengths can ever be negative, I'll remove it
> In theory we should use xdiff_compare_lines here
> as the rest of the lines could have more white space issues,
> but we catch that earlier via a die("color-moved-ws:
> allow-indentation-change cannot be combined with other
> white space modes"), so memcmp is fine.
>
> Side note: There are comments above this code that seem
> to be also obsolete after patch 1 ("...carried forward in
> pmb->wsd; ...)
Good point I'll go through the comments and update them
Best Wishes
Phillip
next prev parent reply other threads:[~2018-10-03 9:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 17:55 [PATCH 1/5] diff --color-moved-ws: fix double free crash Phillip Wood
2018-10-02 17:55 ` [PATCH 2/5] diff --color-moved-ws: fix out of bounds string access Phillip Wood
2018-10-02 18:58 ` Stefan Beller
2018-10-03 9:40 ` Phillip Wood [this message]
2018-10-02 17:55 ` [PATCH 3/5] diff --color-moved-ws: fix a memory leak Phillip Wood
2018-10-02 19:08 ` Stefan Beller
2018-10-03 9:42 ` Phillip Wood
2018-10-03 9:54 ` Martin Ågren
2018-10-02 17:55 ` [PATCH 4/5] diff --color-moved-ws: fix another " Phillip Wood
2018-10-02 19:08 ` Stefan Beller
2018-10-02 17:55 ` [PATCH 5/5] diff --color-moved: fix a " Phillip Wood
2018-10-02 19:11 ` Stefan Beller
2018-10-02 18:49 ` [PATCH 1/5] diff --color-moved-ws: fix double free crash Stefan Beller
2018-10-03 9:38 ` Phillip Wood
2018-10-04 10:07 ` [PATCH v2 0/5] " Phillip Wood
2018-10-04 10:07 ` [PATCH v2 1/5] " Phillip Wood
2018-10-04 10:07 ` [PATCH v2 2/5] diff --color-moved-ws: fix out of bounds string access Phillip Wood
2018-10-04 10:07 ` [PATCH v2 3/5] diff --color-moved-ws: fix a memory leak Phillip Wood
2018-10-04 10:07 ` [PATCH v2 4/5] diff --color-moved-ws: fix another " Phillip Wood
2018-10-04 10:07 ` [PATCH v2 5/5] diff --color-moved: fix a " Phillip Wood
2018-10-04 19:42 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea197dba-bb51-0dde-bd2b-84709ce81a51@talktalk.net \
--to=phillip.wood@talktalk.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.