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

Re: [PATCH 7/9] http: discard hash in dumb-http http_object_request

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 3, 2026, 13:47 UTC
Message-ID
<ake9Wng-Q9p_sf_H@fruit.crustytoothpaste.net>
In-Reply-To
<akecqPq4F702E8Cq@pks.im>
On 2026-07-03 at 11:27:36, Patrick Steinhardt wrote:
Show 15 quoted lines
> On Thu, Jul 02, 2026 at 04:07:07AM -0400, Jeff King wrote:
> > The flag handling could be removed if the hash-discard function were
> > idempotent. This could be done easily-ish by having the underlying
> > hash functions (like the ones in sha256/openssl.h) set the context
> > pointer to NULL after free-ing. But it's something that every platform
> > implementation would have to remember to do, and the benefit for the
> > callers is not that huge (it would let us shave a few lines here and
> > probably in a few other spots).
> 
> This answers an earlier question of mine. It would indeed be great if it
> was idempotent -- I've been bitten by interfaces like this once too
> much, where you have to be very careful to manage the lifetime of a
> specific object. The prime example of this are (were? I don't quite
> recall whether we fixed that interface) reference transactions, and that
> caused a bunch of bugs in the past.

Yes, that would be fantastic. The Rust code will need a few fixes as well (which I will send on top of this one when it's picked up) and it really simplifies our Drop implementation if I can just do `git_hash_discard`. Otherwise, I need to keep track of whether we've already called one of the final functions or not to avoid a double free.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Patrick SteinhardtNext: Jeff King
Message 15 of 20 in “hash algorithm leak fixes”
  1. 0/9 hash algorithm leak fixesJeff King, Jul 2, 2026
  2. 1/9 csum-file: drop discard_hashfile()Jeff King, Jul 2, 2026
  3. Junio C HamanoJul 2, 2026
  4. Jeff KingJul 2, 2026
  5. Patrick SteinhardtJul 3, 2026
  6. 2/9 hash: add discard primitiveJeff King, Jul 2, 2026
  7. Patrick SteinhardtJul 3, 2026
  8. 3/9 csum-file: always finalize or discard hashJeff King, Jul 2, 2026
  9. 4/9 csum-file: provide a function to release checkpointsJeff King, Jul 2, 2026
  10. Patrick SteinhardtJul 3, 2026
  11. 5/9 patch-id: discard hash when doneJeff King, Jul 2, 2026
  12. 6/9 check_stream_oid(): discard hash on read errorJeff King, Jul 2, 2026
  13. 7/9 http: discard hash in dumb-http http_object_requestJeff King, Jul 2, 2026
  14. Patrick SteinhardtJul 3, 2026
  15. brian m. carlsonJul 3, 2026
  16. Jeff KingJul 6, 2026
  17. Jeff KingJul 6, 2026
  18. Patrick SteinhardtJul 6, 2026
  19. 8/9 hash: fix memory leak copying sha256 gcrypt handlesJeff King, Jul 2, 2026
  20. 9/9 hash: add platform-specific discard functionsJeff King, Jul 2, 2026

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.