archive mirror
 help / color / mirror / Atom feed
From: Jeff King <>
To: Junio C Hamano <>
Cc: Jonathan Nieder <>,
	Han-Wen Nienhuys <>,,
Subject: Re: Re* [PATCH v7 1/1] sideband: highlight keywords in remote sideband output
Date: Sat, 18 Aug 2018 19:22:21 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Sat, Aug 18, 2018 at 09:16:28AM -0700, Junio C Hamano wrote:

> -- >8 --
> Subject: [PATCH] sideband: do not read beyond the end of input
> The caller of maybe_colorize_sideband() gives a counted buffer
> <src, n>, but the callee checked src[] as if it were a NUL terminated
> buffer.  If src[] had all isspace() bytes in it, we would have made
> n negative, and then
>  (1) made number of strncasecmp() calls to see if the remaining
>      bytes in src[] matched keywords, reading beyond the end of the
>      array (this actually happens even if n does not go negative),
>      and/or
>  (2) called strbuf_add() with negative count, most likely triggering
>      the "you want to use way too much memory" error due to unsigned
>      integer overflow.
> Fix both issues by making sure we do not go beyond &src[n].

Thanks. I've been sporadically seeing "fatal: you want to use way too
much memory" the last few days while running 'next', and finally managed
to catch a reproducible case. This patch definitely fixes it.

> In the longer term we may want to accept size_t as parameter for
> clarity (even though we know that a sideband message we are painting
> typically would fit on a line on a terminal and int is sufficient).
> Write it down as a NEEDSWORK comment.

This "typically" made me nervous about what happens in the non-typical
case, but I think we can say something even stronger: the length comes
from a pktline, so the maximum is less than 16 bits. I wondered if we
might ever call this on the accumulated string from multiple sidebands,
but it doesn't look like it.


  reply	other threads:[~2018-08-18 23:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07 12:51 [PATCH v7 0/1] sideband: highlight keywords in remote sideband output Han-Wen Nienhuys
2018-08-07 12:51 ` [PATCH v7 1/1] " Han-Wen Nienhuys
2018-08-17 18:33   ` Junio C Hamano
2018-08-17 18:44     ` Re* " Junio C Hamano
2018-08-18  6:09       ` Jonathan Nieder
2018-08-18 14:40         ` Junio C Hamano
2018-08-18 16:02           ` Junio C Hamano
2018-08-18 16:16             ` Junio C Hamano
2018-08-18 23:22               ` Jeff King [this message]
2018-08-20 14:21                 ` Junio C Hamano
2018-08-20 12:21               ` Han-Wen Nienhuys
2018-08-20 12:21                 ` Han-Wen Nienhuys
2018-08-20 14:32                 ` Junio C Hamano
2018-08-18  6:35       ` Jonathan Nieder
2018-08-18 16:06         ` Junio C Hamano
2018-08-07 21:01 ` [PATCH v7 0/1] " Junio C Hamano
2018-08-08 13:12   ` Han-Wen Nienhuys

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:

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

  git send-email \ \ \ \ \ \ \ \

* 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).