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

Re: [PATCH] attr: fix msan issue in read_attr_from_index

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2024, 20:08 UTC
Message-ID
<xmqqmsnj5o3r.fsf@gitster.g>
In-Reply-To
<pull.1747.git.1718654424683.gitgitgadget@gmail.com>
"Kyle Lippincott via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Make the call to `read_attr_from_buf` conditional on `buf` being
> non-NULL, ensuring that `size` is not read if it's never set.
Makes good sense.
Show 25 quoted lines
> Signed-off-by: Kyle Lippincott <spectral@google.com>
> ---
>     attr: fix msan issue in read_attr_from_index
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1747%2Fspectral54%2Fmsan-attr-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1747/spectral54/msan-attr-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1747
>
>  attr.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/attr.c b/attr.c
> index 300f994ba6e..a2e0775f7e5 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -865,7 +865,8 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
>  		stack = read_attr_from_blob(istate, &istate->cache[sparse_dir_pos]->oid, relative_path, flags);
>  	} else {
>  		buf = read_blob_data_from_index(istate, path, &size);
> -		stack = read_attr_from_buf(buf, size, path, flags);
> +		if (buf)
> +			stack = read_attr_from_buf(buf, size, path, flags);
>  	}
>  	return stack;
>  }

Not directly related to the issue this patch addresses, but I notice that both buf and size variables have unnecesarily wide scope. As a clean-up we may want to move their declaration into this "} else {" block. But that is totally outside the scope (no pun intended) of this patch.

Will queue. Thanks.

Previous: Kyle Lippincott via GitGitGadgetNext: Junio C Hamano
Message 2 of 6 in “attr: fix msan issue in read_attr_from_index”
  1. attr: fix msan issue in read_attr_from_indexKyle Lippincott via GitGitGadget, Jun 17, 2024
  2. Junio C HamanoJun 17, 2024
  3. Junio C HamanoJun 17, 2024
  4. Junio C HamanoJun 17, 2024
  5. Kyle LippincottJun 17, 2024
  6. Jeff KingJun 18, 2024

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.