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

Re: [PATCH] sha1_file: don't convert off_t to size_t too early to avoid potential die()

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2014, 17:49 UTC
Message-ID
<xmqqfvfjlf4k.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1411293806-3087-1-git-send-email-prohaska@zib.de>
Steffen Prohaska <prohaska@zib.de> writes:
Show 16 quoted lines
> xsize_t() checks if an off_t argument can be safely converted to
> a size_t return value.  If the check is executed too early, it could
> fail for large files on 32-bit architectures even if the size_t code
> path is not taken.  Other paths might be able to handle the large file.
> Specifically, index_stream_convert_blob() is able to handle a large file
> if a filter is configured that returns a small result.
>
> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
> ---
>
> This patch should be applied on top of sp/stream-clean-filter.
>
> index_stream() might internally also be able to handle large files to
> some extent.  But it uses size_t for its third argument, and we must
> already die() when calling it.  It might be a good idea to convert its
> interface to use off_t and push the size checks further down the stack.

Yes, if we want to futz in this area, I think that would be the right approach.

Previous: Steffen ProhaskaNext: Junio C Hamano
Message 2 of 3 in “sha1_file: don't convert off_t to size_t too early to avoid potential die()”
  1. sha1_file: don't convert off_t to size_t too early to avoid potential die()Steffen Prohaska, Sep 21, 2014
  2. Junio C HamanoSep 22, 2014
  3. Junio C HamanoSep 22, 2014

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.