git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/2] builtin/blame: fix out-of-bounds write with blank boundary commits

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 10, 2025, 13:00 UTC
Message-ID
<992502eb-5131-228e-1915-a35038211f4b@gmx.de>
In-Reply-To
<20250110-b4-pks-blame-truncate-hash-length-v3-2-e61f25b68f30@pks.im>
Hi Patrick,
On Fri, 10 Jan 2025, Patrick Steinhardt wrote:
Show 13 quoted lines
> diff --git a/builtin/blame.c b/builtin/blame.c
> index d7630ac89cb7bd6e9ce5d72c6a98aa433b3b12da..7555c445abe7ca2fa54670ac8fee1d95a6dbafe3 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -489,9 +489,9 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
>  			fputs(color, stdout);
>
>  		if (suspect->commit->object.flags & UNINTERESTING) {
> -			if (blank_boundary)
> -				memset(hex, ' ', length);
> -			else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
> +			if (blank_boundary) {
> +				memset(hex, ' ', strlen(hex));
Using `strlen()` is a neat trick.

I could have done without slipping in a style change (introducing curlies), but the most important thing is that it fixes the bug.

Thank you, Johannes

> +			} else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
>  				length--;
>  				putchar('^');
>  			}
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 17 of 18 in “builtin/blame: fix out-of-bounds read with excessive `--abbrev`”
  1. builtin/blame: fix out-of-bounds read with excessive `--abbrev`Patrick Steinhardt, Jan 9, 2025
  2. Kristoffer HaugsbakkJan 9, 2025
  3. Johannes SchindelinJan 9, 2025
  4. Patrick SteinhardtJan 9, 2025
  5. Johannes SchindelinJan 9, 2025
  6. Johannes SchindelinJan 10, 2025
  7. Patrick SteinhardtJan 10, 2025
  8. builtin/blame: fix out-of-bounds read with excessive `--abbrev`Patrick Steinhardt, Jan 9, 2025
  9. shejialuoJan 9, 2025
  10. Johannes SchindelinJan 9, 2025
  11. shejialuoJan 10, 2025
  12. Johannes SchindelinJan 9, 2025
  13. Junio C HamanoJan 9, 2025
  14. 0/2 builtin/blame: fix out-of-bounds reads and writesPatrick Steinhardt, Jan 10, 2025
  15. 1/2 builtin/blame: fix out-of-bounds read with excessive `--abbrev`Patrick Steinhardt, Jan 10, 2025
  16. 2/2 builtin/blame: fix out-of-bounds write with blank boundary commitsPatrick Steinhardt, Jan 10, 2025
  17. Johannes SchindelinJan 10, 2025
  18. Junio C HamanoJan 10, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.