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

Re: [PATCH 1/1] mingw: safe-guard a bit more against getenv() problems

From
Jeff King <peff@peff.net>
Date
Feb 21, 2019, 13:52 UTC
Message-ID
<20190221135207.GA20899@sigill.intra.peff.net>
In-Reply-To
<53e3d159c8c80924188f57c44efd2170612f2ee5.1550243863.git.gitgitgadget@gmail.com>
On Fri, Feb 15, 2019 at 07:17:45AM -0800, Johannes Schindelin via GitGitGadget wrote:
Show 18 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> Running up to v2.21.0, we fixed two bugs that were made prominent by the
> Windows-specific change to retain copies of only the 30 latest getenv()
> calls' returned strings, invalidating any copies of previous getenv()
> calls' return values.
> 
> While this really shines a light onto bugs of the form where we hold
> onto getenv()'s return values without copying them, it is also a real
> problem for users.
> 
> And even if Jeff King's patches merged via 773e408881 (Merge branch
> 'jk/save-getenv-result', 2019-01-29) provide further work on that front,
> we are far from done. Just one example: on Windows, we unset environment
> variables when spawning new processes, which potentially invalidates
> strings that were previously obtained via getenv(), and therefore we
> have to duplicate environment values that are somehow involved in
> spawning new processes (e.g. GIT_MAN_VIEWER in show_man_page()).

Belated review, as this is already in master, but: yes, I absolutely support this patch, even on top of my patches. Those were just the cases I found by poking around for a few minutes, and I'm sure there are many more.

-Peff
Previous: Jeff King
Message 7 of 7 in “Safe-guard the Windows code a bit more against getenv() problems”
  1. 0/1 Safe-guard the Windows code a bit more against getenv() problemsJohannes Schindelin via GitGitGadget, Feb 15, 2019
  2. 1/1 mingw: safe-guard a bit more against getenv() problemsJohannes Schindelin via GitGitGadget, Feb 15, 2019
  3. Jeff HostetlerFeb 15, 2019
  4. Junio C HamanoFeb 15, 2019
  5. Johannes SchindelinFeb 18, 2019
  6. Jeff KingFeb 21, 2019
  7. Jeff KingFeb 21, 2019

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.