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

Re: [PATCH decompress BUG] Fix decompress_next_from() wrong argument value

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2008, 07:31 UTC
Message-ID
<7vir1zwlcw.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<e5bfff550801112306g6b8127dft80484c9fd8554992@mail.gmail.com>
"Marco Costalba" <mcostalba@gmail.com> writes:
Show 18 quoted lines
> The only two points in the current code in master that I would like to
> report to you are a _possible_ missing inflateEnd() before a new
> inflateInit(), but I am not confident with that part of code to judge
> if is a bug or not, anyway that's the _possible_ diff.
>
> diff --git a/http-push.c b/http-push.c
> index 55d0c94..e0a4cc6 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -307,6 +307,7 @@ static void start_fetch_loose(struct
> transfer_request *request)
>  	/* Reset inflate/SHA1 if there was an error reading the previous temp
>  	   file; also rewind to the beginning of the local file. */
>  	if (prev_read == -1) {
> +		inflateEnd(&request->stream);
>  		memset(&request->stream, 0, sizeof(request->stream));
>  		inflateInit(&request->stream);
>  		SHA1_Init(&request->c);

I think this could leak if request->stream already had something in it, but I do not see anything that is done to it after it is initialized and the code reaches to this point.

In fact, I suspect that it would make more sense to remove the earlier memset() that clears request->stream and inflateInit(), and moving the memset() and inflateInit() we see above out of that if clause (before checking prev_read).

The same comment applies to the other hunk.

By the way, I was looking at the earlier two series from you (compress and decompress), and noticed some of them were corrupt with linewrap. As I think they are good clean-up patches, I'd like to apply them as one of the first series post 1.5.4. As such, this request is not urgent at all, but please resend with a clean-up when 'master'/'next' reopens.

Thanks.
Previous: Marco CostalbaNext: Marco Costalba
Message 4 of 6 in “Fix decompress_next_from() wrong argument value”
  1. Fix decompress_next_from() wrong argument valueMarco Costalba, Jan 11, 2008
  2. Junio C HamanoJan 12, 2008
  3. Marco CostalbaJan 12, 2008
  4. Junio C HamanoJan 12, 2008
  5. Marco CostalbaJan 12, 2008
  6. Junio C HamanoJan 12, 2008

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.