git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Branko Majic <branko@majic.rs>
To: git@vger.kernel.org
Subject: [BUG] Integer overflow when supplying large context value to  diff --unified
Date: Fri, 9 Feb 2018 16:01:47 +0100	[thread overview]
Message-ID: <20180209160147.3f54a362@majic.rs> (raw)

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

Hello,

Git versions tested: 2.13.6, 2.1.4

When passing-in a large context value for the --unified option for
git-diff, Git will produce an invalid-looking range information for
hunks.

For example, if running 'git diff --unified=10 HEAD^', the output will
include (this is just a run against my local git repo):

@@ -42,23 +42,23 @@ master_doc = 'index'

Note the numbers for denoting begin/end line etc "look fine"(they're
within the expected numeric range).

Now, if we pass on a big value to it (2 to the power of 32 divided by 2,
e.g. enough so that signed long int can't hold it without overflowing),
e.g. 'git diff --unified=2147483648 HEAD^', the output will include
(again, just a sample):

@@ -2147483700,4294967295- +2147483700,4294967295- @@

Note that the begin/end line numbers are way out of range. The diff
itself will actually contain no context lines.

Best regards

-- 
Branko Majic
XMPP: branko@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: branko@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2018-02-09 15:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180209160147.3f54a362@majic.rs \
    --to=branko@majic.rs \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).