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

Re: [PATCH 11/11] bug_fl(): add missing `va_end()` call

From
Jeff King <peff@peff.net>
Date
Jun 16, 2022, 19:20 UTC
Message-ID
<YquCaE+Vw9P/fybU@coredump.intra.peff.net>
In-Reply-To
<xmqqk09gtriq.fsf@gitster.g>
On Thu, Jun 16, 2022 at 11:03:25AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> 
> > But obviously that's a bad use of the varargs API, I just don't know how
> > we've been getting away with it in practice, sorry about that.
> 
> Exactly.  We three all expressed our surprises on why it "works".
> Nobody offered an explanation, though, which leaves us in suspense
> ;-)

Being the curious sort, I ran it in a debugger. And indeed, "cp" is filled with uninitialized garbage. The reason it works is that the test calls bug() with a format string that does not contain any placeholders. And thus our eventual call to vsnprintf() does not ever look at "cp" at all!

Show 5 quoted lines
> > The fix Peff's got here LGTM. I can (re)submit it with
> > format-patch+send-email after giving it a commit message describing the
> > issue if you'd like, but the change would be the same.
> 
> Yup, I think the code change there looks the most sensible.

I'll wrap it up with a commit message and modify the test to be more thorough.

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 35 of 38 in “Coverity fixes”
  1. 00/11 Coverity fixesJohannes Schindelin via GitGitGadget, Jun 15, 2022
  2. 01/11 mingw: avoid accessing uninitialized memory in `is_executable()`Johannes Schindelin via GitGitGadget, Jun 15, 2022
  3. Junio C HamanoJun 16, 2022
  4. René ScharfeJun 16, 2022
  5. Junio C HamanoJun 16, 2022
  6. Junio C HamanoJun 16, 2022
  7. 02/11 fsmonitor: avoid memory leak in `fsm_settings__get_incompatible_msg()`Johannes Schindelin via GitGitGadget, Jun 15, 2022
  8. Junio C HamanoJun 16, 2022
  9. 03/11 submodule--helper: avoid memory leak in `update_submodule()`Johannes Schindelin via GitGitGadget, Jun 15, 2022
  10. Junio C HamanoJun 16, 2022
  11. Glen ChooJun 16, 2022
  12. 04/11 get_oid_with_context_1(): avoid use-after-freeJohannes Schindelin via GitGitGadget, Jun 15, 2022
  13. Junio C HamanoJun 16, 2022
  14. 05/11 submodule-config: avoid memory leakJohannes Schindelin via GitGitGadget, Jun 15, 2022
  15. Junio C HamanoJun 16, 2022
  16. Glen ChooJun 16, 2022
  17. 06/11 pack-redundant: avoid using uninitialized memoryJohannes Schindelin via GitGitGadget, Jun 15, 2022
  18. Junio C HamanoJun 16, 2022
  19. 07/11 submodule--helper: avoid memory leak when fetching submodulesJohannes Schindelin via GitGitGadget, Jun 15, 2022
  20. Junio C HamanoJun 16, 2022
  21. 08/11 read_index_from(): avoid memory leakJohannes Schindelin via GitGitGadget, Jun 15, 2022
  22. 08/11 read_index_from(): avoid memory leakTom Levy, Jun 17, 2022
  23. 09/11 pack-mtimes: avoid closing a bogus file descriptorJohannes Schindelin via GitGitGadget, Jun 15, 2022
  24. Taylor BlauJun 16, 2022
  25. 10/11 relative_url(): fix incorrect conditionJohannes Schindelin via GitGitGadget, Jun 15, 2022
  26. Junio C HamanoJun 16, 2022
  27. Ævar Arnfjörð BjarmasonJun 16, 2022
  28. Junio C HamanoJun 16, 2022
  29. Junio C HamanoJun 16, 2022
  30. 11/11 bug_fl(): add missing `va_end()` callJohannes Schindelin via GitGitGadget, Jun 15, 2022
  31. Jeff KingJun 16, 2022
  32. Junio C HamanoJun 16, 2022
  33. Ævar Arnfjörð BjarmasonJun 16, 2022
  34. Junio C HamanoJun 16, 2022
  35. Jeff KingJun 16, 2022
  36. bug_fl(): correctly initialize trace2 va_listJeff King, Jun 16, 2022
  37. Junio C HamanoJun 16, 2022
  38. Junio C HamanoJun 16, 2022

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.