git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 0/4] apply --whitespace=fix buffer corruption fix
Date: Thu, 22 Jan 2015 14:58:21 -0800	[thread overview]
Message-ID: <1421967505-16879-1-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <xmqq1tmnwypp.fsf@gitster.dls.corp.google.com>

"git apply --whitespace=fix" used to be able to assume that fixing
errors will always reduce the size by e.g. stripping whitespaces at
the end of lines or collapsing runs of spaces into tabs at the
beginning of lines.  An update to accomodate fixes that lengthens
the result by e.g. expanding leading tabs into spaces were made long
time ago but the logic miscounted the necessary space after such
whitespace fixes, leading to either under-allocation or over-usage
of already allocated space.

The second patch in this series is to illustrate this with a runtime
sanity-check to protect us from future breakage (this is a reroll of
a "how about this" weatherbaloon patch $gmane/262579, with Kyle's
test script).

The third patch corrects the under-counting and makes the new test
pass.

The fourth patch makes us report the fact that we corrected
whitespace errors in the common-context part.  When asked to correct
whitespace errors, and given a patch that has whitespace errors in
the common context (i.e. the lines prefixed with " ") either in the
patch itself or the corresponding part in the file we are patching,
we have been correcting the whitespace errors "while at it" since
around c1beba5b (git-apply --whitespace=fix: fix whitespace fuzz
introduced by previous run, 2008-01-30), but we were not reporting
that we saw a need to fix them.

This is not about the "buffer corruption fix", which is the primary
focus of this series, but it is here because it is related to
whitespace fix.


Junio C Hamano (4):
  typofix
  apply: make update_pre_post_images() sanity check the given postlen
  apply: count the size of postimage correctly
  apply: detect and mark whitespace errors in context lines when fixing

 builtin/apply.c               |  34 ++++++++++--
 t/t4138-apply-ws-expansion.sh | 121 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+), 3 deletions(-)
 create mode 100755 t/t4138-apply-ws-expansion.sh

-- 
2.3.0-rc1-116-g84c5016

  parent reply	other threads:[~2015-01-22 22:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 18:20 Segmentation fault in git apply Michael Blume
2015-01-14 18:40 ` Michael Blume
2015-01-14 18:44   ` Michael Blume
2015-01-14 18:48     ` Michael Blume
2015-01-14 18:58       ` Michael Blume
2015-01-14 19:09         ` Michael Blume
2015-01-15  8:26           ` Kyle J. McKay
2015-01-15  9:10             ` Kyle J. McKay
2015-01-16 19:58               ` Junio C Hamano
2015-01-16 23:54                 ` [PATCH] apply: count the size of postimage correctly Junio C Hamano
2015-01-18 10:49                   ` [PATCH] test: add git apply whitespace expansion tests Kyle J. McKay
2015-01-18 22:11                     ` Junio C Hamano
2015-01-19  3:54                       ` Kyle J. McKay
2015-01-21 22:33                         ` Junio C Hamano
2015-01-22  6:55                           ` Kyle J. McKay
2015-01-22 19:23                             ` Junio C Hamano
2015-01-23  0:12                               ` Kyle J. McKay
2015-01-22 22:58                           ` Junio C Hamano [this message]
2015-01-22 22:58                             ` [PATCH v2 1/4] apply.c: typofix Junio C Hamano
2015-01-22 23:17                               ` Stefan Beller
2015-01-22 23:42                                 ` Junio C Hamano
2015-01-22 23:48                                   ` Stefan Beller
2015-01-22 22:58                             ` [PATCH v2 2/4] apply: make update_pre_post_images() sanity check the given postlen Junio C Hamano
2015-01-22 22:58                             ` [PATCH v2 3/4] apply: count the size of postimage correctly Junio C Hamano
2015-01-22 22:58                             ` [PATCH v2 4/4] apply: detect and mark whitespace errors in context lines when fixing Junio C Hamano
2015-01-14 18:50 ` Segmentation fault in git apply Junio C Hamano

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=1421967505-16879-1-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).